I am still working throughout the current coronavirus outbreak, although at a reduced capacity. Please do get in contact if you have any questions.

Select Page

If you are getting the ‘Analytics snippet does not look valid’ error then you can follow these simple steps to get your Google Analytics code installed on your Shopify store. If you prefer, you can watch the video on how to do it below.

Installing Google Analytics to Shopify was as simple as pasting a UA code in to a field in the preferences menu. That was before Google updated the Analytics tag to version 4 and in turn changed the the tracking code. Unfortunately Shopify haven’t reacted to this quickly enough, so people using the new tags can’t add them in to the preferences menu. This is just a quick way to get it installed in the meantime.

You will not need to be a developer to do this but you will need to update the code in your theme. It is advised to duplicate your theme before doing this, so you have a backup of the theme if things go wrong. But don’t worry, this is a simple change and that is just a precaution, better safe than sorry! You can do this under ‘Online Store’ in the ‘Themes’ menu but selecting ‘Duplicate theme in the actions menu’.

Install google analytics in Shopify - Duplicating theme

From the same theme menu, if you select ‘edit code’ from the dropdown it will open the code editor. In the left hand side select the file called ’theme.liquid’ under the ‘Layout’ section. Then you need to find this tag </head>, it is on around line 165 in most themes, you can search for it using ctrl + f or cmd + f on a Mac. Once you have located it, you need to paste your Google Analytics tracking snippet just above it. Now hit save in the top right of the page.

Analyics snippet does not look valid - Install Google Analytics to Shopify
Install Google Analytics to Shopify - adding analytics tag

Once this is done, you can head over to Google Analytics and test it in the ‘real time’ reporting section. All you need to do is click on a few pages of your website and it should start to come up in Google Analytics.

Analyics snippet does not look valid - testing analytics tag

Eventually Shopify will fix the Google Analytics tracking box and then you are free to move the code out of the theme template and back in to the admin preferences. The benefit of doing this is that you can switch the theme and your Google Analytics tracking will still work. If you do decide to switch to a new theme in the interim period of them fixing, just make sure the tracking code is present.

Install Google Analytics 4 tracking code to Shopify Video