How to Add Google Analytics to Shopify: A Step-by-Step Guide

Do you want to add Google Analytics to your Shopify website so you can track site traffic and other key metrics? Adding Google Analytics lets you take control of your website and make informed decisions to improve your traffic. Read on to learn how to add Google Analytics to your Shopify website in three simple steps.

Don’t have a Shopify website yet? Check out our guide on How to Make a Shopify Website.

Want to learn how to use Google Analytics? Take this online course created by Google.


Step 1: Create a Google Analytics Account

Before you can add Google Analytics to your Shopify website, you must create a Google Analytics account.

To create a Google Analytics account:

  1. Visit the Google Analytics website.
  2. Either sign in to your Google account or create a new one, then click on the blue “Start measuring” button.                                      How to Add Google Analytics to Shopify.
  3. In the “Account name” field, enter an account. Typically, this will be the name of your business.                                       How to Add Google Analytics to Shopify.
  4. Decide what data you want to share with Google, and then click on the “Next” button.
  5. You’ll then arrive on a “Property details” screen. Your property name is the name of your website, and it is typically the same name as your business. 
  6. In the “Property name” field, enter your property name, select your time zone and local currency, then click on the “Next” button.                                        How to Add Google Analytics to Shopify.
  7. You’ll arrive on a “Business information” screen. 
  8. Select your “Industry category” and “Business size.” Also, check the appropriate boxes under “How do you intend to use Google Analytics with your business?” and then click the “Create” button.                                     How to Add Google Analytics to Shopify.
  9. Decide which email communications you want to receive regarding Google Analytics, check the appropriate boxes, then click the “Save” button.                          How to Add Google Analytics to Shopify.
  10. Under “Set up a data stream to start collecting data,” click on the “Web” button.                                  How to Add Google Analytics to Shopify.
  11. Under “Website URL,” enter your website’s address, not including its security protocol.
  12.  Under “Stream name,” enter the name of your website. Leave “Enhanced Measurement” turned on and click on the “Create stream” button.                                      How to Add Google Analytics to Shopify.
  13. Scroll down to “Global site tag (gtag.js)” and click the down arrow icon to open a section of code.
  14. You will need to copy the entire block of code that appears by clicking the copy icon on the right side of the code box. Don’t let the word “code” scare you off — adding this to your website is simple and easy.                             How to Add Google Analytics to Shopify.
  15. Continue to Step 2.

Step 2: Connect Google Analytics to Your Shopify Site

Now that you have a Google Analytics account and copied the “Global site tag” code, it’s time to add this information to your Shopify website.

To connect your Google Analytics account to your Shopify website:

  1. Sign in to your Shopify account. You should automatically be navigated to your site’s main dashboard.                               How to Add Google Analytics to Shopify.
  2. From the dashboard, click on the “Online Store” button.
  3. Here, you will be able to see a preview of your current theme.
  4. Click “Actions” and then click “Edit code.” to continue.                               How to Add Google Analytics to Shopify.
  5. Locate “theme.liquid” under “Layout” and click to continue.                                     How to Add Google Analytics to Shopify.
  6. Click where it says “<Head>” on line 3.                                             How to Add Google Analytics to Shopify.
  7. Click the enter key three times to add three additional lines below line 3.                                    How to Add Google Analytics to Shopify.
  8. Click on line 4, then paste the code you copied earlier.                                   How to Add Google Analytics to Shopify.
  9. Click the green “Save” button in the top-right corner to finish your work.

Congratulations! You’ve connected your Google Analytics account to your Shopify website. However, bear in mind that you may have to wait 24 to 48 hours for site data to start showing up in your Google Analytics account.

Step 3: Confirm the Connection to Shopify

Finally, you should make sure you connected your Google Analytics account to your Shopify website correctly.

To confirm the connection:

  1. Open your Shopify website — not your website editor, but the browser version of your website. 
  2. In a new tab, go to the Google Analytics website and log in to your account.                                How to Add Google Analytics to Shopify.
  3. Click on the “Realtime” option in the menu on the left.                        How to Add Google Analytics to Shopify.

Because you are currently visiting your website in another tab, the number “1” should appear under “Users in Last 30 Minutes.”

Google Analytics mentions that traffic may take up to 24 hours to appear in the Google Analytics dashboard. If your website still doesn’t show any traffic after 24 hours, repeat the steps in this article to ensure you were successful in adding Google Analytics to Shopify.

Final Thoughts

Now that you can track the traffic to your Shopify website with Google Analytics, work to increase that traffic by following the advice in these related articles:

What Does a Good Website Need?
How People Find Your Website: SEO 101
How to Improve SEO
Small Business Marketing Strategies

Additional Resources