global site tag

New Member
5 0 0

Hi there,

 

where exactly  would I insert global site tag? 

 

<head>

<!-- Basic page needs ================================================== -->
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">

{% if settings.favicon %}
<link rel="shortcut icon" href="{{ settings.favicon | img_url: '32x32' }}" type="image/png" />
{% endif %}

<!-- Title and description ================================================== -->
<title>
{{ page_title }}{% if current_tags %}{% assign meta_tags = current_tags | join: ', ' %} &ndash; {{ 'general.meta.tags' | t: tags: meta_tags }}{% endif %}{% if current_page != 1 %} &ndash; {{ 'general.meta.page' | t: page: current_page }}{% endif %}{% unless page_title contains shop.name %} &ndash; {{ shop.name }}{% endunless %}
</title>

{% if page_description %}
<meta name="description" content="{{ page_description | escape }}">
{% endif %}

<!-- Helpers ================================================== -->
{% include 'social-meta-tags' %}
<link rel="canonical" href="{{ canonical_url }}">
<meta name="viewport" content="width=device-width,initial-scale=1,shrink-to-fit=no">
<meta name="theme-color" content="{{ settings.color_primary }}">

<!-- CSS ================================================== -->
{{ 'timber.scss.css' | asset_url | stylesheet_tag }}
{{ 'theme.scss.css' | asset_url | stylesheet_tag }}

<!-- Sections ================================================== -->
<script>
window.theme = window.theme || {};
theme.strings = {
zoomClose: {{ "products.zoom.close" | t | json }},
zoomPrev: {{ "products.zoom.prev" | t | json }},
zoomNext: {{ "products.zoom.next" | t | json }},
moneyFormat: {{ shop.money_format | json }},
addressError: {{ 'home_page.map.address_error' | t | json }},
addressNoResults: {{ 'home_page.map.address_no_results' | t | json }},
addressQueryLimit: {{ 'home_page.map.address_query_limit_html' | t | json }},
authError: {{ 'home_page.map.auth_error_html' | t | json }},
cartEmpty: {{ 'cart.general.empty' | t | json }},
cartCookie: {{ 'cart.general.cookies_required' | t | json }},
cartSavings: {{ 'cart.general.savings_html' | t: savings: '[savings]' | json }}
};
theme.settings = {
cartType: {{ settings.cart_type | json }},
gridType: {{ settings.collection_products_grid | json }}
};
</script>

{{ 'jquery-2.2.3.min.js' | asset_url | script_tag }}

<script src="{{ 'lazysizes.min.js' | asset_url }}" async="async"></script>

<script src="{{ 'theme.js' | asset_url }}" defer="defer"></script>

<!-- Header hook for plugins ================================================== -->
{{ content_for_header }}

{{ 'modernizr.min.js' | asset_url | script_tag }}

{% comment %}
If you store has customer accounts disabled, you can remove the following JS file
{% endcomment %}
{% if request.page_type contains 'customers/' %}
{{ 'shopify_common.js' | shopify_asset_url | script_tag }}
{% endif %}

</head>

0 Likes
Shopify Partner
1043 112 165

You have to add it to the theme.liquid under layout folder, Shopify code editor. I would recommend making a copy of the original file just in case you'd want to easily rollback.

Sergiu Svinarciuc | CTO @ visely.io
- Was my reply helpful? Click Like to let me know!
- Was your question answered? Mark it as an Accepted Solution!
- To learn more about the awesome stuff we do head over to visely.io or our blog
0 Likes
New Member
5 0 0

Thank you, but before I make a booble,

 

Do I need to delete the current code,  and insert the new one


@Visely-Team wrote:

You have to add it to the theme.liquid under layout folder, Shopify code editor. I would recommend making a copy of the original file just in case you'd want to easily rollback.



in there? ( I will save it somewhere first in case as you said something goes wrong) 

0 Likes
Shopify Partner
1043 112 165

You'll have to take the important bits from the code you share below and inject them into the <head>...</head> in theme.liquid. I see the code is from a different theme or something, so just copying over everything is definitely a bad idea.

Sergiu Svinarciuc | CTO @ visely.io
- Was my reply helpful? Click Like to let me know!
- Was your question answered? Mark it as an Accepted Solution!
- To learn more about the awesome stuff we do head over to visely.io or our blog
0 Likes
New Member
5 0 0

I am but  I  am now confused.

do I delete the code old code and insert the new one or 

do I need to add the new code below the old code inside the header?

 

I am not a tech savvy, sorry.

0 Likes
Shopify Partner
1043 112 165

If you can paste here the content of your current theme.liquid file, I can try and do a meaningful merge for you.

Sergiu Svinarciuc | CTO @ visely.io
- Was my reply helpful? Click Like to let me know!
- Was your question answered? Mark it as an Accepted Solution!
- To learn more about the awesome stuff we do head over to visely.io or our blog
0 Likes
New Member
5 0 0

You are absolutely the best, here we are.

 

<!-- Global site tag (gtag.js) - Google Ads: 706702643 -->
<script async src="https://www.googletagmanager.com/gtag/js?id=AW-706702643"></script>
<script>
window.dataLayer = window.dataLayer || [];
function gtag(){dataLayer.push(arguments);}
gtag('js', new Date());

gtag('config', 'AW-706702643');
</script>

0 Likes
Shopify Partner
1043 112 165

OK, assumed the long piece of code you share in your original post is the code you are looking to insert, and no the actual code from your store. Now that we are all set, you can add google tag manager code just above </head> element in your theme.liquid.

Sergiu Svinarciuc | CTO @ visely.io
- Was my reply helpful? Click Like to let me know!
- Was your question answered? Mark it as an Accepted Solution!
- To learn more about the awesome stuff we do head over to visely.io or our blog
0 Likes
Highlighted
New Member
5 0 0

It was successfully saved.

Thank you so much. 

0 Likes