Where should I place the Google Analytics global site tag in my theme code?

Solved

Where should I place the Google Analytics global site tag in my theme code?

jpshivell
Tourist
30 0 2

I am trying to edit the code for my store to add Google Analytics, which requires a global site tag. I can get to the "edit code" area through the "Actions" tab, but now I have a list of pages, none of which I recognize. How do I determine where to put the tag?

Accepted Solution (1)

Stefano468
Shopify Partner
33 2 4

This is an accepted solution.

Hi Jpshivell,

 

  there is a much easier wait to install you Google UA global Tag in a Shopify store, rather then editing the code.

I assume you have already your UA HTML code copied: simply go to Sales Channels/Online Store/Preferences and scroll down till the section Google Analytics. There you can paste your HTML code and name the property in the title. Activate also "advanced eComemrce" for more detailed demographics data collection and you are done! Shopify inserts in all the website pages your UA global Tag. I hope this helps, take care!

# Was my reply helpful? Click Like to let me know!

# Was your question answered? Mark it as an Accepted Solution

Free shop Quality Audit | eCommerce 360° Strategy | Front end customisation | Klaviyo eMail remarketing workflow | Planyo Booking engine integration.
My contact: stefano@crystalitg.com

View solution in original post

Replies 2 (2)

Stefano468
Shopify Partner
33 2 4

This is an accepted solution.

Hi Jpshivell,

 

  there is a much easier wait to install you Google UA global Tag in a Shopify store, rather then editing the code.

I assume you have already your UA HTML code copied: simply go to Sales Channels/Online Store/Preferences and scroll down till the section Google Analytics. There you can paste your HTML code and name the property in the title. Activate also "advanced eComemrce" for more detailed demographics data collection and you are done! Shopify inserts in all the website pages your UA global Tag. I hope this helps, take care!

# Was my reply helpful? Click Like to let me know!

# Was your question answered? Mark it as an Accepted Solution

Free shop Quality Audit | eCommerce 360° Strategy | Front end customisation | Klaviyo eMail remarketing workflow | Planyo Booking engine integration.
My contact: stefano@crystalitg.com
jpshivell
Tourist
30 0 2

I tried your solution, but I keep getting an error, possibly because I copied and pasted the wrong code. This is the code I pasted into the form:

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

gtag('config', 'G-6LLQ99XZVK');
</script>

When I paste the code, I get the following error message: Analytics snippet does not look valid (UA-xxxx-x)

The reason I think I have the wrong code is because I do not see a "UA" anywhere. So, where do I get the proper code?