How to Add Google Analytics to Shopify (Google Analytics 4 Guide)

How to add Google Analytics to Shopify (the Google Analytics and Shopify logos side by side).

In this simple step by step guide, we show you exactly how to add Google Analytics to your Shopify store.

Note: at time of writing, the regular method of connecting Google Analytics in the Shopify admin only works with the old version of Google Analytics, ‘Universal Analytics.’ This will shortly be discontinued.

But this article gives you a simple workaround that lets you use the new version, Google Analytics 4, with any Shopify account.


What is Google Analytics 4?

Google Analytics 4 is the latest version of Google’s free analytics tool; it replaces the company’s ‘Universal Analytics’ product, which has been in use since 2012.

Google Analytics 4 provides more detailed information about user behavior on your website or online store (specifically where conversions and user journeys are concerned).

But it also gives people visiting your site more protection when it comes to their privacy.

Google Analytics dashboard.
The Google Analytics dashboard.

Some of the data Google Analytics 4 gives you includes…

  • a real time overview of your website traffic
  • the location of your users
  • how users got to your store pages
  • what type of device visitors used to access your store
  • how long people spend on your store
  • what they have added to their baskets

…and much more.

There is a very wide range of reports in the tool, and Google Analytics lets you filter your data and visualize the specific data sets you need. It’s well worth adding the tool to your Shopify store, even if you’re happy with the built-in reporting features of Shopify (Google Analytics can give you a lot of additional context about your users!).

Website events report in Google Analytics.
A Google Analytics report on specific website events

Right, let’s get to it.


How to set up Google Analytics 4 in Shopify

1. Create a Google account

In order to use Google Analytics you need to have a Google account.

(If you already have a Gmail account or a Google Workspace account, you’re all set and can jump ahead to step 2 now.)

If you don’t have any kind of Google account yet, you’ll need to go to the Google account sign-up page.

You simply enter your details into the fields provided and click ‘Next’.

The Google account creation page.
The Google account creation page

Note that you don’t need a Gmail address to create a Google account. Google gives you the option to use an email address with another provider, such as Yahoo or Outlook.

You’ll then need to provide some additional information to Google, such as your phone number and a recovery email address for your account. You’ll also need to accept Google’s terms of service.

Once done, you will be brought to your new Google account page.

Google account page.
Google account page

2. Set up Analytics and get your tracking code

To set up a Google Analytics account, sign in to Google Analytics.

When you do this, you’ll see a blue ‘Start measuring‘ button in the middle of the Analytics welcome page.

'Start measuring' button in Google Analytics.
The first step in the Google Analytics setup process

Click on this button.

You’ll then be taken to the Google Analytics account setup screen.

The first thing you need to do is enter an account name for your Google Analytics account. It is usually best to simply go with the name of your business for this.

Naming your Google Analytics account.
Naming your Google Analytics account

You can then choose the type of data you wish to share with Google.

Having done that, click ‘Next.’

You will now see the ‘Property setup‘ section.

Tip: In Google terminology, a ‘property’ is basically all the data associated with an individual website with a unique URL, for example: ‘puregrains.com’. If you have multiple websites for your online business, you can set up multiple properties top to track customer behavior on each one.

(In this case we will stick to setting up Google Analytics tracking on a single website.)

Enter the name of your business in the property name field and choose your preferred time zone and currency. Then, click ‘Next‘.

Entering 'property' details in google Analytics.
Entering ‘property’ details

You now have the option to enter some information about your business such as your business industry, the size of your company and how you intend to use Google Analytics.

(You can skip this step if you wish.)

Next, click ‘Create‘.

At this point you need to accept Google’s terms of service for using Google Analytics.

Make sure that you select your country / region in the top left corner of the panel.

Google Analytics Terms of Service Agreement.
Google Analytics Terms of Service Agreement

If your business is located in the EU (or some of your customers are located there), you’ll also need to tick the check box beside ‘I also accept the Data Processing Terms as required by GDPR’. 

Once you’ve done that, click ‘I Accept‘.

You will now be brought to the Admin page of your Google Analytics account for your new property.

The Google Analytics property Admin page.
The Google Analytics property Admin page

Go to the ‘Choose a platform‘ section, and click on the ‘Web‘ button.

Choosing the platform type in Google Analytics.
Choosing a platform

You will then see a page that lets you create a ‘data stream’ between Google Analytics and your Shopify store.

Google Analytics web stream creation page.
Google Analytics web stream creation page

You now need to enter your store’s domain into the ‘website URL‘ field.

Note: in the below example, we’re using a ‘myshopify.com’ domain. However, you will probably be using a custom domain name (yoursitename.com etc.).

Then enter your business name into the ‘Stream name’ box

Completing the web stream section in google Analytics.
Completing the web stream section in google Analytics

Then click ‘Create stream’.

On the page that appears, scroll down to the ‘Google tag’ section and click ‘Configure tag settings’.

Tag settings in Google Analytics.
Tag settings

On the next page, click ‘Installation instructions‘ in the ‘Your Google tag’ section.

Accessing installation instructions.
Accessing installation instructions

And on the page that appears, click ‘Install manually‘.

Install manually settings.
Accessing the ‘install manually’ settings and the Google Analytics tracking tag

You’ll then see your Google tag code. Copy this code to your clipboard.

Copying Google tag manually.
Google Analytics tracking code

Next, go to your Shopify store account. Navigate to Online Store > Themes, and then click on the three dots beside your theme’s ‘Customize’ button and click ‘Edit code’.

Accessing theme code in Shopify
Accessing theme code in Shopify

Next, click on ‘theme.liquid‘ in the menu on the left hand side of the page.

Adding the Google tag code below in a Shopify theme's code.
Adding the Google Analytics code to your Shopify theme

Place your cursor to the right of the ‘<head>’ text inside your Shopify theme’s. Hit return on your keyboard to go to a new line and paste in your Google tag code here (just below the ‘<head>’ tag).

Once that’s done, click ‘Save’.

Congratulations — you’ve just enabled Google Analytics on your Shopify store!

But you’re not quite done yet. You’ve got to…

3. Test that Google Analytics 4 is connected to your Shopify store

Now that you’ve completed all the necessary steps to connect Google Analytics 4 to your Shopify store, it’s time to test that everything is working as it should.

To do this, you can simply enter your store domain name into a web browser.

View some of your store pages and interact with your store for a few seconds. This will create some data on your Shopify store that Google Analytics will gather through the connection you have just set up.

Then, go back to Google Analytics and click on ‘Real-time’ in the Google Analytics menu.

This will show you some information on current store visitors as well as visits in the last 30 minutes.

Google Analytics 'real-time overview'.
Google Analytics data showing you a ‘real-time overview’ of site visitors

If you see anything like the image above, you know that Google Analytics 4 is now successfully connected to your Shopify store and gathering data on your customers’ behavior across your store’s pages.

And that’s it!

I hope you find this explanation of how to enable Google Analytics on your Shopify store useful.

If you have any questions, please feel free to add them to the comments section below — we read them all and will do our best to help.

Don’t miss out on our free ecommerce e-kit

For a limited time, we’re offering our readers some excellent free tools. Sign up free to immediately receive:

  • our online store comparison chart
  • a downloadable cheatsheet on how to create an online store
  • our SEO, blogging and ‘how to start a business’ cheatsheets
  • extended free trials and discount codes for essential business apps
  • our latest tips on ecommerce and growing a business
  • This field is for validation purposes and should be left unchanged.

View privacy notice.

No comments

Your email address will not be published. Required fields are marked *