Is placing Google analytic tag after the head element correct?

Topic summary

Correct placement of Analytics code in a Shopify theme: the script must be inserted inside the element (between and ), not after the closing . This allows Google to recognize the tag.

A later case involved a “G-XXXXXXX” tag (GA4 Measurement ID) appearing as text at the top-left of the storefront. A screenshot helped identify it as GA4. For GA4, the correct method is to use Shopify’s Google Channel integration rather than pasting code in the theme:

  • Admin > Online store > Preferences > Manage pixel here
  • Connect your Google account
  • Select the GA4 Measurement ID
  • Connect the GA4 property
  • Remove any manually added tag from the theme

If a tag renders on the page, it’s likely placed in the rather than within .

Outcomes:

  • Original question resolved by moving the tag inside .
  • GA4 case resolved by connecting via Google Channel and removing manual code.

Newest update: another user asked for the code and setup. Guidance: use your own unique Google-provided tag and follow Google’s setup documentation before applying the relevant method above.

Status: Key issues resolved; thread open for further questions.

Summarized with AI on January 14. AI used: gpt-5.

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 tag as opposed to the .

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,