Stape
Search
Try for free

Server-side Google Ads conversion tracking in Shopify

Updated
Jul 16, 2024
Published
Oct 24, 2023

Shopify is the top e-commerce platform that lots of business owners use to build and run their online shops. Many Shopify store owners count on Google Ads to boost their online store sales as a crucial way to connect with potential customers.

The main factor for a successful online advertising campaign is precise conversion tracking. Server-side tracking is a great way to capture accurate and comprehensive data about user interactions on your website, minimizing the impact of cookie restrictions and ad blockers.  

In this article, we will show how to implement server-side Google Ads conversion tracking for Shopify stores using Stape’s server GTM app for Shopify

Why transitioning to server-side tracking is important

Server-side tracking technology has become increasingly popular in recent years, and there are several reasons for this trend. The primary factor is that server-side tracking is well-suited to the evolving landscape of tracking regulations and restrictions, making it a better choice than traditional web tracking methods.

Below are some situations where server-sid tracking can help to increase the accuracy of tracking:

  1. Limitation on the use of third-party cookies. All popular browsers except Chrome are already limiting the use of third-party cookies. On the other hand, marketing and analytics platforms rely on third-party cookies when tracking user conversions and behaviors. Recently, Safari even started to block first-party cookies set from third-party IPs. Chrome will begin phasing out of third-party cookies in 2024. With the help of the server-side tracking, you can set first-party cookies instead of third-party or set first-party cookies from the first-party IP.
  2. Use of AdBlockers. Over the last few years the number of people who installed AdBlcokers has multiplied. With the help of server-side tracking, you can still accurately track people with adblockers.
  3. Blocking of Google Tag Manager, Google Analytics, and other tracking scripts. Safari and Brave are blocking web Google Tag Manager, GA and some other tracking scripts. When web GTM is blocked, all tracking that is supposed to trigger inside the web GTM is blocked as well. The good news is that gtm script is not blocked when you use server-side GTM with a custom domain.

How to set up Google Ads conversion tracking for your Shopify store

2.1. Install Stape Server GTM App in store. 

Activate the app in Sales channels → Online Store → your active theme → Customize button → App embeds tab → activate Stape server GTM app and click Save.

install Stape Server GTM App in store. 

2.2. In the Generate tab are all the settings related to installing the GTM snippet on all pages of your Shopify shop.

In the Generate tab are all the settings related to installing the GTM snippet on all pages of your Shopify shop
  • GTM web container id

Here you need to specify your GTM WEB container ID.

  • Custom domain

It is extremely important to use your own subdomain for first party cookies to work correctly and for tracking to work in general. If you do not already have a subdomain added to your sGTM container, you can use this guide to add it.

  • Custom loader

An optional parameter, but its use is highly recommended to increase protection against ad blockers.

Specify here your Stape container identifier. Follow this guide to find Stape container identifier.

  • Cookie Keeper

You can learn more about Cookie Keeper power-up on this page.

This allows you to minimize the impact of the latest ITP restrictions.

Before activating this feature, make sure you have it enabled in Stape, in your container.

  • GTM snippet block

Here you can take the GTM snippet to install it on pages that are outside of your Shopify theme (such as pages made by third-party apps like Zipify).

2.3. In the Data Layer tab you can find the data layer events to activate and configure.

In the Data Layer tab you can find the data layer events to activate and configure

Data layer activation:

  • Activate the 'Add ecommerce Data Layer events' checkbox.
  • Save changes.
  • Copy the code for custom pixel in the box below on data layer tab and follow the instructions to add and activate it.

In Customer privacy section, under Permission spoiler, please make sure to select ‘Not required’. The code snippet only generates dataLayer, it does not set any cookies or report any data to third-party.

2.4. Webhook events are configured in the Webhook tab.

Note: the problem with webhooks on Shopify is that they don't contain any cookie data which is crucial for tracking any platform, so using webhook events is only recommended as a last resort if you for some reason can't track it online.

This tab is where the webhook events are configured.

Webhook events are configured in the Webhook tab

To activate a webhook you need to activate the checkbox, specify the url of the server GTM container and /path where the webhooks should be sent.

You can subscribe to webhooks when a new order is created or when a refund is made on an order.

Here are some useful blog posts we have about using and debugging webhooks:

3. Send data to Google Analytics 4 with the server Google Tag Manager container.

There can be two scenarios:

1. If you already have GA4 events configured in your web GTM container and you just want to switch them to work through the server side.

If you already configured Google Analytics 4 inside your web GTM container, all you need to do is:

a. Add your server container URL to Google Tag settings. In the configuration settings, add the configuration parameter server_container_url and add your tagging server URL as a value. 

Add your server container URL to Google Tag settings

b. Create Google Analytics 4 client in server GTM container. In most cases, it already exists straight away. But if not you can create it.

To do so, open the clients’ section → Create New client → Select client type Google Analytics: GA4 (Web) → Add client name and click save. 

Create Google Analytics 4 client in server GTM container

c. In the server GTM container create a new tag with the tag type Google Analytics: GA4.

d. Add Measurement ID and Event Name.

Measurement ID -  Follow this guide to find GA4 ID. You can add it as variable or if the event came from a GA4 web tag, you can leave this field blank to inherit the measurement ID of the event.

Event Name - the event name to send to Google. You can leave this field blank and the same event_name will be used as in your GA4 tag on the web container.

Event Name - the event name to send to Google. 

e. Click Triggering and configure a trigger with the trigger type Custom that will fire every time when client name equals GA4 (or the name of the GA4 client that you’ve specified on the step 2.b) → Click save. 

Click Triggering and configure a trigger with the trigger type Custom

2. If you do not have GA4 configured, follow the steps bellow:

2.1. Inside the Web container, create a new tag of the tag Type Google Tag. Add your Google Tag ID.

Add trigger to GA4 tag. It usually should trigger on standard ‘Initialization - All Pages’ trigger. 

create a new tag of the tag Type Google Tag

Google tag itself will generate standard GA4 events like page_view, session_start, user_engagement, etc.

2.2. Setting up additional ecommerce events. 

Each event you want to configure must be configured with a separate GA4 event tag, use its own trigger and have its own payload.

Below is an example of configuring the tag for the add_to_cart event with standard parameters. You can repeat this for any other events you want to configure.

You can also use any custom events if you want to track them in your GA4.

Stape Shopify app generates a data layer with standard ecommerce events (if you have activated this option in the app). You can view each event in the GTM preview mode of the web container to see if it is working correctly and its payload, but also here is the documentation for each event: https://help.stape.io/hc/en-us/articles/13693436542877-Shopify-App-dataLayer

2.2.1. Set up trigger.

Go to triggers section in your web container → create new trigger with type ‘Custom Event’ → specify trigger name ‘add_to_cart_stape’ according to the Stape Shopify App dataLayer doc.

create new trigger with type ‘Custom Event’

2.2.2 Setup variables for GA4 events payload.

You can find the standard and mandatory payload ecommerce GA4 events in the official documentation: https://developers.google.com/tag-platform/gtagjs/reference/events

A minimum of three parameters need to be sent with each ecommerce event:

  • value
  • currency
  • items

All of them are available in the data layer that generates the Stape Shopify app.

To add these parameters to an event, you must first create variables for them.

To do this, go to 'Variables' section in your web container → create a new one → select 'Data Layer Variable' type → specify the path to the required value as per how they are in the data layer. 

for value path: ecommerce.value

for currency: ecommerce.currency

for items: ecommerce.items

Сreate these three variables:

2.2.3 Set up GA4 event tag.

Go to the tags section in your web GTM container  and create a new tag with the tag type Google Analytics: GA4 Event

In the tag, specify:

  • Measurement ID: your GA4 measurement id
  • Event name: add_to_cart (or other if you are setting up another event)
  • On GA4 event tag ‘Event parameters’ section add three parameter: value, currency and items. Use the variables you created in the previous step as the value for them.
  • Add to the tag the add_to_cart_stape trigger we created earlier.
Google Analytics: GA4 Event

Similarly, configure any other events you want to track in your GA4.

3.1. Configuration in the server GTM container.

In the 'Clients' section, check if you have a GA4 client there. If not, create new one:

GA4 client

Choose Google Analytics: GA4 (web) and click Save.

GA4 client

3.2. Create GA4 tag on server GTM container.

Go to Tags and click New.

Create GA4 tag on server GTM container

Choose Google Analytics: GA4.

Choose Google Analytics: GA4.

Standard tag settings:

Measurement ID - Leave blank, the same measurement id that is in your web events will be used

Event Name - leave blank, the same event name you use in web tags will be used.

3.3. Add trigger.

Click Triggering. 

adding trigger to GA4 tag

Create triggers for the tag.

Client name should equal GA4. Click +

Client name should equal GA4. Click +

Choose Custom type →  click Some events →  choose Client Name in built-in variables →  set Equals GA4 (the name of your GA4 client) →  click Save. 

Equals GA4 (the name of your GA4 client)

Done, now all your GA4 events will come from your web container to the server container and further sent to GA4.

4. Set up Conversion Linker tag + Google Ads Conversion Tracking tag.

In the Server container set up the Conversion Linker tag. This tag should trigger on all events claimed by the GA4 client (the same trigger that is used for GA4 server tag, on the screenshot above).

In the Server GTM container click New Tag → click Tag configuration → Google Ads → Google Ads Conversion Tracking tag. Add Conversion ID and Conversion Label similarly to the web Adwords tag setup.

Then you have an option to add product and user data. If you send user and product data from the web to the server, then you can enable these checkboxes and select event data as a data source. If product and user info are properly sent from the web using standard dimensions and are available in the event data - the tag will parse this information automatically and report to Google Ads. You also have an ability to override the data sent from the web if needed. My Adwords server conversion triggers on the purchase event.

Google Ads Conversion Tracking tag

Conclusion

Setting up Google Ads conversion tracking in your Shopify store is an indispensable step for anyone aiming to harness the full potential of online advertising. As the digital marketplace becomes increasingly competitive, such insights are invaluable in staying ahead of the curve and maximizing your ROI. 

Whether you're a seasoned advertiser or just beginning your journey, ensure that your Shopify store is equipped with Google Ads conversion tracking to truly capitalize on every advertising dollar spent.

If you have any questions about the setup - don’t hesitate to leave a ticket. And if you’d like a setup from us - here’s a free quote!

Tagged with:Google AdsShopify

Host your GTM server at Staperight now!