• Explore. Learn. Thrive. Fastlane Media Network

  • ecommerceFastlane
  • PODFastlane
  • SEOfastlane
  • AdvisorFastlane
  • LifeFastlane

How To Install Google Analytics 4 On Shopify

How To Install Google Analytics 4 On Shopify

Google will be sunsetting Universal Analytics in July 2023, and moving everything to GA4. This means website owners need to get GA4 set up as soon as possible. Find out how in our step-by-step guide. ,

By now you should know that Google retired Universal Analytics in July 2023, and moved everything to GA4. This means that website owners need to get GA4 set up as soon as possible. For ecommerce websites there’s the added complication of getting ecommerce tracking working in GA4 too. For Shopify stores this process was really simple on Universal Analytics, but is more challenging on GA4.

Read on for an easy process to set up GA4 ecommerce tracking on any Shopify website without needing to install apps or use developers.

To complete this process you’ll need to have both GTM and GA4 already installed on your Shopify store. For help with this, read our guides on How To Install GTM on Shopify and How To Install GA4 on Shopify.

Whilst anyone should be able to follow this guide, it will be easier if you have a basic understanding of how GTM works.

Talk To Us About Shopify Support


How To Set Up Google Analytics 4 on Shopify

Before you can start gathering data about your store, you need to have a Google Analytics account and create a GA4 property. You can then set up Google Analytics 4 tags on your Shopify store, and connect your Google Ads account with your Google Analytics account.

Step 1: Create a Google account and Google Analytics account

You need a Google account to use Google Analytics. If you already use Google products, such as Gmail or Ads, then you can use the same account for Google Analytics.

If you don’t already have an account for a Google product, then create a Google account. You don’t have to use the Gmail account for anything other than signing in and out of Google Analytics.

After you create a Google account, you need to Create an Analytics account. Then proceed to step 2.

Step 2: Create or move a Google Analytics 4 property

To activate Google Analytics 4, either create a new Google Analytics 4 property to add to your Shopify store, or move an existing property that you previously created.

After you have your property, you need to create a web data stream. Make a note of the Tag ID because you’ll use it in Step 3.

Step 3: Add Google Analytics 4 tags

If you don’t have the Google & YouTube channel installed, then you’re prompted to install it during the set up process for your GA4 tags. You don’t have to connect to the Google Merchant Center to complete your GA4 tags setup process.

Steps:

  • From your Shopify admin, got to Online store > Preferences.
  • In the Google Analytics section, click Manage pixel here.
  • Click Connect your Google account.
  • Select the Tag ID for the GA4 property that you want to connect to your Shopify store.
  • Click Connect your Google Analytics 4 property.
  • After you set up Google Analytics 4 tags, certain ecommerce events are tracked automatically. To learn more about event tracking in Google Analytics 4, refer to Setting up Google Analytics events.

Note Google Analytics can’t track events until you remove password protection from your online store.

Step 4: Link your Google Analytics account to your Google Ads account

Linking a Google Analytics property to your Google Ads account helps you to analyse customer activity on your store that you can use to measure conversion actions and create audiences.


Let’s work together to build your store

We are one of the world’s most trusted and experienced Shopify Plus Partners.

Get in touch

Create Data Layer In Shopify

Our first task is to create a data layer. The data layer is a simple bit of code that contains information about a visitor’s website session. This information can then be passed to other platforms such as GTM.

We’ve created a data layer for you that goes on the Shopify order-complete page. It automatically populates itself with information about the customer’s order, such as order value, shipping costs and items purchased.

  • Copy and paste the script below into the ‘checkout’ scripts field in your Shopify admin settings. This can be found by going to ‘Settings > Checkout & Accounts > Additional Scripts’

  • This data layer pushes a ‘purchase’ event to GTM that contains information about the customer’s order.

{% if first_time_accessed %}  {% endif %}**

Let’s work together to build your store

We are one of the world’s most trusted and experienced Shopify Plus Partners.

Get in touch

How to set up GA4 with GTM

Create Firing Trigger in GTM

Now we need to set up a trigger that fires when customers complete an order. When the trigger fires, the tag that contains the order information is sent to GA4.

We need to define the conditions on which our purchase trigger fires. The condition for our trigger will be when the purchase event in our data layer is pushed. To set this up:

  • Log into GTM, go to the left menu and select ‘Triggers’
  • Press the blue ‘New’ button
  • Call your trigger ‘GA4 – Purchase’
  • Press the ‘edit’ icon in the corner of the ‘Trigger Configuration’ window
  • Under ‘Choose trigger type’ select ‘Custom Event’
  • In the ‘Event name’ field type ‘purchase’
  • Set ‘This trigger fires on’ to ‘Some custom events’
  • Set the event conditions to:
  • Event – Equals – Purchase

When you’re finished, it should look like this:

GA4 ecommerce setup


Let’s work together to build your store

We are one of the world’s most trusted and experienced Shopify Plus Partners.

Get in touch

Create Data Layer Variables in GTM

Before we set up our tag, we need to create GTM variables to grab information from our data layer. If variables are new to you, think of them as packets that contain small bits of information.

Specific values from the data layer are added into these variables, and these are then sent to GA4.

We need to create variables to extract the following values from your datalayer:

  • Order Revenue

  • Order ID

  • Currency

  • Tax

  • Shipping Costs

  • Items Purchased

  • In GTM, from the left menu click into the ‘Variables’ page

  • In the ‘User-Defined Variables’ box click on the ‘New’ button

  • On this screen you can create a new GTM variable. You need to do the following process for each of the variables listed above. The details for each individual variable is listed below:

Order Revenue

Name: dlv – Thank You Page – Order Revenue

Variable Configuration:

Variable Type: Data Layer Variable

Data Layer Variable Name: ecommerce.value


Order ID

Name: dlv – Thank You Page – Order ID

Variable Configuration:

Variable Type: Data Layer Variable

Data Layer Variable Name: ecommerce.transaction_id


Currency

Name: dlv – Thank You Page – Currency

Variable Configuration:

Variable Type: Data Layer Variable

Data Layer Variable Name: ecommerce.currency


Tax

Name: dlv – Thank You Page – Tax

Variable Configuration:

Variable Type: Data Layer Variable

Data Layer Variable Name: ecommerce.tax


Shipping Costs

Name: dlv – Thank You Page – Shipping

Variable Configuration:

Variable Type: Data Layer Variable

Data Layer Variable Name: ecommerce.shipping


Items Purchased

Name: dlv – Thank You Page – Items

Variable Configuration:

Variable Type: Data Layer Variable

Data Layer Variable Name: ecommerce.items


Each variable should look similar to this when complete:

setting up Google Analytics 4 for ecommerce

Learn More About Our Ecommerce Services

Let’s work together to build your store

We are one of the world’s most trusted and experienced Shopify Plus Partners.

Get in touch

Create Ecommerce Tags in GTM

To pull ecommerce data into GA4, GTM needs to fire a tag on the order-complete page. This tag contains information about each order and is used to populate the GA4 reports.

  • Go back into GTM and from the left menu click into ‘Tags’
  • Press the blue ‘New’ button
  • Name your tag ‘GA4 Purchase’
  • In the ‘Tag Configuration’ box press the edit icon in the top right corner
  • Select ‘Google Analytics: GA4 Event’
  • In the ‘Configuration Tag’ field, select your ‘GA4 Config’ tag.
  • In the ‘Event Name’ field, enter “purchase”
  • Expand the ‘Event Parameters’ drop down menu and press ‘Add Row’

Event parameters are bits of information about the order that we want to pull through to GA4 when the tag fires. Think of event parameters as the individual elements of a customer order (such as order value, shipping costs etc). Each of these elements need to be added as an event parameter against the purchase event tag.

To set these up, click the ‘Add Row’ button. Each row has two fields

  • Parameter Name – The official name of the parameter defined by GA4. When a purchase event fires with one of GA4’s defined purchase parameters, GA4 will recognise it. For example, ‘transaction_id’, ‘tax’ and ‘shipping’ are both recognised purchase parameters. A full list of available purchase event parameters can be viewed here.

  • Value – The actual value of the parameter. This will be a dynamic value based upon the customer ordered. Using the example parameters above, these could be:

transaction_id: #245

tax: 2.56

shipping: 3.99

The event parameter values are dynamic bits of information from your data layer. Remember the data layer variables we created earlier? It’s those variables which are used to populate the event parameter values.

Click the icon to the right hand side of the ‘value’ field. This will load a screen where you can select a variable. Find and select the correct variable for this parameter (it will be one of the ones you created earlier that begins with “dlv”).

Do this for the following parameters:

Parameter Name Value
items {{dlv – Thank You Page – Items}}
value {{dlv – Thank You Page – Order Revenue}}
transaction_id {{dlv – Thank You Page – Order ID}}
tax {{dlv – Thank You Page – Tax}}
shipping {{dlv – Thank you Page – Shipping}}
currency {{dlv – Thank You Page – Currency}}

When complete, your screen should look like this:

ga4 parameters


Let’s work together to build your store

We are one of the world’s most trusted and experienced Shopify Plus Partners.

Get in touch

Debugging

Finally, we need to test that our tag setup is working. To do this:

  • Go into GTM and press the ‘Preview’ button in the top right corner
  • Follow the steps to activate GTM preview mode on your store
  • Once complete it will take you to the front end of your store with a tag assistant window in the corner

GA4 tag assistant

The previous tab (titled “Tag Assistant [Connected]) will now report on the tags that fire as you browse your site in the preview tab.

  • Open your GA4 account and in the left menu go to ‘Configure > DebugView’
  • Go back to the tab that previews your store front end and put through a test transaction
  • Finally, go into the GA4 DebugView tab. If the GA4 purchase tag has successfully fired, you’ll see a green purchase event in the timeline. Click into this event and the window on the right will populate with information about the order.

GA4 purchase timeline


Let’s work together to build your store

We are one of the world’s most trusted and experienced Shopify Plus Partners.

Get in touch

Publish GTM Changes

Once you’re happy that transactions are captured within your GA4 ecommerce tracking, you can go ahead and publish your GTM changes. After publishing, we recommend paying close attention to both your GA4 account and your UA account to make sure that orders are recorded as you would expect.


Let’s work together to build your store

We are one of the world’s most trusted and experienced Shopify Plus Partners.

Get in touch

Install GA4 With GTAG On Shopify

Another effective way to install GA4 for Shopify is through GTAG. Firstly, you need to ensure your GA4 property is setup correctly and then add your Shopify URL by clicking on Data Streams > Web and then inserting it there, then click Create Stream.

Next, go to Data Streams in your GA4 property and select your new stream. Copy the measurement ID (it starts with ‘G’). Then in your Shopify admin, go to Online Store . Themes and find your active theme. Click Actions > Edit Code and then under Layout, click on theme.liquid. Add the GTAG script code just before the tag. Replace G-XXXXXXXXXX with your GA4 Measurement ID and save the changes.

Don’t forget to verify the changes in Google Analytics by going to Realtime in the left sidebar. We recommend visiting your Shopify site and performing an action to confirm that your activity shows up in GA4’s Realtime report.


Let’s work together to build your store

We are one of the world’s most trusted and experienced Shopify Plus Partners.

Get in touch

How To Set Up GA4 With Google & YouTube Channel App

You can also use the Google & Youtube Channel App to set up GA4 by connecting a new or existing Google account. This will help to share your Shopify store data with Google Analytics and track its performance. Simply go to your Shopify admin, click Settings > Apps and sales channels > Google & YouTube and then click connect Google Account.

In the Looking only to set up Google Analytics 4? banner, click Get started. Then in the Connect a Google Analytics property section, you will need to select your existing property from the drop-down list. The GA4 IDs listed are the IDs associated with your Google account where your Google account is an administrator. If you don’t have a GA4 property, then click Create new, and then create a property from Google Analytics. Then finally, click Connect.

To test that your GA4 with the Google & Youtube App works, use the DebugView in GA4. But first you need to download the Google Analytics Debugger Chrome Extension and then you click on its icon so that you see the ON ribbon. This will allow you to see your events in DebugView. You can find the DebugView in Admin > DebugView in your GA4 property.

If you go to your Shopify store URL with the analytics DebugView extension enabled, you should see events come into the DebugView.


Let’s work together to build your store

We are one of the world’s most trusted and experienced Shopify Plus Partners.

Get in touch

Speak with our expert team for more advice

Thanks for reading our guide – we hope it helped you get set up. If you need any further advice or help with your Shopify store, marketing or SEO, drop us a message and one of our team will get in touch.

If you enjoyed this guide, why not check out our 2023 Ultimate Guide to SEO on Shopify? Written by our team of SEO experts, it’s packed full of useful tips and methods to improve your store’s search performance, grow traffic and increase sales. Click the button below to have it emailed direct to you.

Download the Ultimate Guide to SEO


To stay up to date with all things ecommerce, make sure you subscribe using the form below to receive our weekly newsletters, guides and advice.

,

We are one of the world’s most trusted and experienced Shopify Plus Partners. A full-service, fully in-house digital agency of over 50 talented people, we’ve helped hundreds of ambitious brands exceed their goals.

,

Eastside Co leads the way in UX-focused Shopify web design, results-driven marketing strategies, and best-in-class Shopify applications and software. We help online businesses escape the ordinary and achieve ecommerce success.

This article originally appeared on Eastside Co and is available here for further discovery.
Prev
How To Use Data-Driven Marketing To Drive Sales
how-to-use-data-driven-marketing-to-drive-sales

How To Use Data-Driven Marketing To Drive Sales

Next
What Is Benchmarketing?
what-is-benchmarketing?

What Is Benchmarketing?

You May Also Like
Share to...