SOP 067: How to add Google Analytics to a Shopify Store
To add Google Analytics to a Shopify store and verify that it is working properly.
Google Analytics is properly added without any technical issues.
Google Analytics is the most popular tool to measure website data to gather visitor insights. With it, you will be able to know the amount of traffic you are getting, and how your visitors are behaving inside your website.
In Shopify’s Admin Panel and Google Analytics.
Only once—the first time you install Google Analytics.
The person responsible for website management, or analytics.
Create and set up a Google Analytics Account
-
If you are not logged in to your Google account you will be prompted to log in:
3. If you are already logged in to your Google Account but you don’t yet have a Google Analytics account, you will want to create one now by pressing “Sign Up”:
Note: Your Google Account can be used for multiple Google services (e.g. Gmail, Adwords, Analytics, etc) but you still have to sign up individually for each service.
4. You will now be prompted to fill-in information about your website:
Account Name:
If you want to manage multiple websites under this account you might want to have a name here that applies to all websites.
If you only have one website you might want to type the name of your website, or your business
Account Data Sharing Settings: Optional data-sharing settings that you can opt-in or out of.
5. Click “Next”
Property Name: Write a name that will easily identify the exact website you’ll be tracking. You can even enter the URL of your website If you wish.
Reporting Time Zone: Select the Time Zone that you would like to see being used in your reporting. Usually, this will be the time zone where most of your visitors are located.
Currency: If your website handles transactions, this is where you should select the currency your website uses.
6. Click “Show advanced options” (⚠️ Important Step)
7. Click “Create a Universal Analytics property” and enter the following options:
1. Website URL: Select the right protocol for your website (http:// or https://):
If you don’t know what your website’s protocol is type your website URL in Google Chrome starting with “https://” (e.g. “https://clickminded.com”)
If you see a green padlock before the URL appearing, it means you should select “https://”
If instead you see a red padlock and a “Not Secure” message appearing, you will want to select “http://”
2. Create both a Google Analytics 4 and a Universal Analytics property: Select this option.
Enable enhanced measurement for Google Analytics property: Yes
3. Industry Category / Business Size / How do you intend to use Google Analytics: Select the ones that apply. Don’t worry, this will not have a direct impact on your tracking and is an optional field. It is used by Google to help them improve Google Analytics and compile industry averages.
8. Scroll down to the bottom and click on: “Create”:
9. Read and accept the Terms & Conditions:
10. You will be sent to the Google Analytics account you’ve just created. On the top left corner select your Universal Analytics property (Not the GA4 property):
💡 Note: In addition to the “GA4” at the end of the Property name (indicating the Google Analytics 4 property), you can also identify your Universal Analytics property by noticing the ‘UA-’ prefix in the Property ID below it’s name:
11. Take note of your Google Universal Analytics tracking ID, you will need it for the next steps. This ID will be a code that starts with “UA-”.
Adding your first views
Note: If you have just created your Google Analytics account you will notice you now have one view named “All Web Site Data”. This is alright if you are sure you will not be doing any customizations on your Google Analytics properties.
However, we recommend that you create 3 additional views:
-
Main View: This is your go-to view. This is where you will be doing all your analysis and should be working flawlessly. All customizations to Google Analytics should have already been properly tested in the Staging View as not to affect this view’s data.
-
Staging View: This is your Google Analytics sandbox. If you want to test something new but are unsure how it will affect your data (e.g: creating a new filter) you will want to do it here and give it a few days before migrating the changes to the Master View.
-
Unfiltered View: This view will be left untouched no matter what. No customizations whatsoever will be done to this view.
With this structure, you will always have a way to recover lost data in case something goes wrong. The unfiltered view will always have all your data. And the “Main View” will have all your filters properly applied.
-
Go to your Google Analytics Admin page by clicking here .
-
If you have multiple Analytics accounts make sure the right account and property is selected:
3. Under “View” click on the dropdown box and select “Create a new view”:
4. Insert the view details:
Note: Make sure you select the same “Reporting Time Zone” you have selected for the other views.
5. We’re now going to create the Staging View. To do that, select the “All Web Site Data” from the dropdown. And click on “View Settings”:
6. Click “Copy View”
7. In the “New view name” field type “Staging View”, and click “Copy View”:
8. You should now have these 3 views:
9. All we need now is to rename the original view and we’ll be done. To do it, select the “All Web Site Data” view.
10. Click on “View Settings”:
11. Click on “View Settings” and rename the view name that will now be your “Main View” and hit “Save”:
12. You should now be able to see your first three views:
Enable E-commerce and Enhanced E-commerce tracking
-
Inside your Google Analytics account, on the sidebar, click “Admin”
2. Make sure you’ve selected the right Account, Property, and View on the top → Click “E-commerce Settings”.
Note: If you’ve followed the previous chapters of this SOP you should have now 1 Account, 1 Property, and 3 Views. Remember to first add the new settings to your Staging View. After you’ve confirmed everything is working great, you’ll replicate those on your Main View.
3. Toggle “Enable E-commerce” and “Enable Enhanced E-commerce Reporting”:
4. Click ‘Save’:
5. That’s it! You’ll see a “Success” message on the top and your Google Analytics View will now have E-commerce data once you add the Google Analytics code to Shopify.
Retrieve Google Analytics 4 tracking code
-
Login to your Google Analytics account .
-
Click “Admin”.
3. Make sure you’ve selected the correct property (website) and select “Data Streams”.
4. Select your website that you want to implement Google Analytics 4.
5. Click on the “Global site tag” to view the Google Analytics 4 tracking code.
6. Click the copy icon to copy the Google Analytics 4 tracking code.
7. You can paste it in a text editor or notepad for now. You will need this later.
Adding the Google Analytics 4 tracking code to your Shopify Store
-
Login to your Shopify store .
-
On your Shopify Admin Panel, click 'Online Store' followed by 'Themes'. Then, click on the three dots or kebab menu to reveal the options. Proceed to click 'Edit code'.
3. Click 'theme.liquid', and paste your Google Analytics 4 tracking code (that you copied earlier) right after '<head>'.
4. This is what it looks like after you’ve pasted the code. Then, click 'Save'.
5. Next, go back to your shopify store dashboard and click ‘Preferences’ under ‘Online Store’. Paste your code again in the description box of ‘Google Analytics account’. For existing users, remove your old code and replace it with the new code.
6. That’s it! You’ve now added the Google Analytics 4 tracking code to your Shopify store.
Connecting Google Analytics 4 to your Shopify Store
-
Look for ‘Apps’ on the sidebar and click it:
2. Next, search for google and look for ‘Google channel’.
3. Click on it to add the app into your shopify store.
4. Click ‘Add sales channel’ followed by ‘Connect Google account’.
5. Choose the corresponding email address or account that you have used for your Google Analytics 4 account.
6. Locate the illustrated box below and click ‘Get started’.
Select a Google Analytics 4 property that you have set up previously, click ‘Connect’ and you‘re done!
Verify your setup inside Google Analytics 4
-
To test if the tracking code works, login to your Google Analytics 4 account .
-
You will be taken to your account dashboard.
-
Head to the real-time report under Report ➞ Real-time
4. You should see (at least) 1 active user on the website.
5. Verify the country where the user is from (it should be where you are currently located).
6. If you see user activities on your real-time report, then you can confirm the Analytics 4 has been implemented successfully.