Is placing Google analytic tag after the head element correct?

Solved

Is placing Google analytic tag after the head element correct?

ecoepc
New Member
4 0 0

I am looking to add my google tag to my website, I have followed the manual instructions and pasted the code after the <head> element, is this correct? I have attached a photo, google analytics hasn't recognised it yet so wondering if I have done it wrong?

ecoepc.jpg

Accepted Solution (1)

Olivia
Shopify Staff
1725 148 312

This is an accepted solution.

Hi, @ecoepc!

 

Welcome to Shopify Community and thank you for your question.

 

This is almost right, though you've pasted the tag code right after the closing element of the head tag as denoted by </head>.

 

The opening element, which you will likely find several lines up will look like <head>. The secret is to paste your code in between these two, which would mean it is in the header element. My recommendation is to find the opening <head>, and hit enter to add a line beneath it in which to paste your code.

 

Google should then be able to recognize it immediately once done correctly.

 

Let me know if you have further questions!

Olivia | Social Care @ Shopify 
 - Was my reply helpful? Click Like to let me know! 
 - Was your question answered? Mark it as an Accepted Solution
 - To learn more visit the Shopify Help Center or the Shopify Blog

View solution in original post

Replies 11 (11)

Olivia
Shopify Staff
1725 148 312

This is an accepted solution.

Hi, @ecoepc!

 

Welcome to Shopify Community and thank you for your question.

 

This is almost right, though you've pasted the tag code right after the closing element of the head tag as denoted by </head>.

 

The opening element, which you will likely find several lines up will look like <head>. The secret is to paste your code in between these two, which would mean it is in the header element. My recommendation is to find the opening <head>, and hit enter to add a line beneath it in which to paste your code.

 

Google should then be able to recognize it immediately once done correctly.

 

Let me know if you have further questions!

Olivia | Social Care @ Shopify 
 - Was my reply helpful? Click Like to let me know! 
 - Was your question answered? Mark it as an Accepted Solution
 - To learn more visit the Shopify Help Center or the Shopify Blog

ecoepc
New Member
4 0 0

Thank you so much!

Olivia
Shopify Staff
1725 148 312

I'm so glad I could help, @ecoepc!

 

I appreciate you taking the time to reply and marking my reply as an accepted solution for future readers. If you have further questions around this, please don't hesitate to leave another comment in our thread.

 

Warm regards,

Olivia | Social Care @ Shopify 
 - Was my reply helpful? Click Like to let me know! 
 - Was your question answered? Mark it as an Accepted Solution
 - To learn more visit the Shopify Help Center or the Shopify Blog

everseller
Visitor
1 0 0

dear ecopec would you be so kind of send me an screenshot of how you set up the code i am new into this and i am super lost also could please send me the code without knowing i closed the page and i cnt get it now pleasd i really apreaciate your help kind regards 

Olivia
Shopify Staff
1725 148 312

Hi, @everseller!

 

Thanks for joining our thread. Maybe I can help you out with this.


For starters, you should have your own unique code for tracking purposes so it's important to use the one provided to you by Google during set-up. 

 

Check out this Google Support article for instructions on setting up various types of google tags for reference. Once you've determined that, you can continue to set up with either instruction provided in this forum thread.

 

Warm regards,

Olivia | Social Care @ Shopify 
 - Was my reply helpful? Click Like to let me know! 
 - Was your question answered? Mark it as an Accepted Solution
 - To learn more visit the Shopify Help Center or the Shopify Blog

DaveWood
Tourist
3 0 0

Hello Olivia

 

Sorry to trouble you, wanted to ask if this solution would be the same for me with a G-XXXXXXX tag. I have inserted the tag above the closing head in liquid theme as per instructions but unsure if this is correct as tag is showing in the top left of my homepage. Data seems to be flowing between site and Google.

 

Thank you 

Dave

Olivia
Shopify Staff
1725 148 312

Thanks so much for connecting with me, @DaveWood!

 

Yes, that is correct - the instructions would be the same for you in your theme as well. Though if it is displaying on the actual page's properties then I suspect it is in the <body> tag as opposed to the <header>.

 

If you're comfortable doing so, can you show me a screenshot of the tag in the liquid so I can get a general sense of where it currently sits? Then I can better advise what the next steps should be. Also, be sure to exclude any personal information from your screenshot.

 

I look forward to your reply,

Olivia | Social Care @ Shopify 
 - Was my reply helpful? Click Like to let me know! 
 - Was your question answered? Mark it as an Accepted Solution
 - To learn more visit the Shopify Help Center or the Shopify Blog

DaveWood
Tourist
3 0 0

Morning Olivia

 

Please find attached screenprint of where G-tag is, installation instructions tell you to put it above the closing <head>, which I think I did and data seems to flow but it appears on my Store, top-left corner. I have tried the tag above the opening head as well, same outcome.

 

DaveWood_0-1678351033522.png

 

Hope you can enlarge this, let me know and I will email it to you.

 

Thanks for your help

Dave

Olivia
Shopify Staff
1725 148 312

Thanks for your reply, @DaveWood.

 

My apologies I definitely misunderstood what you meant earlier by a G-***** code. Based on your screenshot you are trying to set up a Google Analytics 4 code. To use this newer version you must install the Google Channel through Shopify.

 

In fact, we have step-by-step instructions you can follow to correctly set up this code. Please check out the full documentation at this link. After setting up the Google Channel as per prompts in your Admin, follow these steps:

 

Steps:

  1. From your Shopify admin, got to Online store > Preferences.
  2. In the Google Analytics section, click Manage pixel here.
  3. Click Connect your Google account.
  4. Select the Measurement ID for the GA4 property you want to connect to your Shopify store.
  5. Click Connect your Google Analytics 4 property.

At that point, make sure to remove it from your code entirely. I trust that will resolve your issue, but let me know if anything else comes up.

 

Warm regards,

Olivia | Social Care @ Shopify 
 - Was my reply helpful? Click Like to let me know! 
 - Was your question answered? Mark it as an Accepted Solution
 - To learn more visit the Shopify Help Center or the Shopify Blog

DaveWood
Tourist
3 0 0

Hello Olivia

 

Perfect, easy when you have the right instructions, I was unaware it was a GA4 tag so probably trying to set it up incorrectly.

 

Everything seems fine now, I set the liquid theme back to it's original setting and then added GA4 so no tag added to theme.

 

Thank you so much for your help as this has been driving me nuts for days trying to work it out! 🙂

 

Take care

Dave

Olivia
Shopify Staff
1725 148 312

Thank you for getting back to me and confirming that worked for you, @DaveWood! I'm so glad I could help, but do let me know if you have further questions about setting up your store.

 

We also have this helpful launch checklist I encourage you to review in the next few days as you prepare to open your store's virtual doors. 

 

Warm regards,

Olivia | Social Care @ Shopify 
 - Was my reply helpful? Click Like to let me know! 
 - Was your question answered? Mark it as an Accepted Solution
 - To learn more visit the Shopify Help Center or the Shopify Blog