Google Analytics

Follow customer journeys with Google Analytics.

Google Analytics is a popular web analytics service used to analyze data collected from your site, e.g. site activity and session duration.

VersionJavascript libraryGoogle support
Classic Google Analytics (GA1) ga.jsDeprecated
Universal Analytics (GA2) analytics.jsUntil July 1, 2023
Universal Analytics (GA3) gtag.jsUntil July 1, 2023
Google Analytics 4 (GA4) gtag.js with a different data modelSupported

Data models

Universal Analytics is an older version of Google Analytics that uses a data model based on sessions and page views. Google Analytics 4 is the most recent version and uses a data model based on events and parameters.

Javascript libraries

If you use analytics.js, Google gives you a tracking ID that you need to add to every page on your site, e.g. UA-00000-2. The tracking ID tells Google Analytics which account and property (site) the collected data belongs to.

If you use gtag.js, then you use tags instead of tracking IDs. The gtag.js library adds a single tag to your site to connect with multiple Google products and services, including Google Analytics.

📘 Note: All Google Analytics accounts since 2017 use gtag.js. Prior to 2017, analytics.js was the default method for tagging.

API integrations

You can add your tracking ID or tag in your integration by adding it in google_analytics.account when you create an order.


Sometimes Google Analytics can miss or incorrectly report part of a customer's journey if they are redirected away from your site. This can be because:

  • The customer pays but doesn't return to your site's success page.
  • When the customer is redirected to your success page, a different browser opens. Google Analytics considers this a new session. For example, from an in-app browser to the default browser, or from the customer's preferred browser to the default browser.
  • When the customer is redirected to your success page from a third-party site. Google Analytics considers this a new session from a different source.
  • The customer has blocked third-party cookies.

This can impact the reliability of Google Analytics reports, and they won't accurately capture conversion rates. There are some ways to mitigate this.

Client side solutions

How to exclude referrals

To prevent third-party shopping carts initiating new sessions, you can exclude referral domains. This prevents the customer being counted as a referral when they return to your success page.

📘 Note: This feature is only available for sites using gtag.js or analytics.js.

For instructions, see Google Analytics – Referral exclusions .

When you click +Add referral exclusion, enter the following:

Referral exclusion list

How to keep sessions alive

To tell Google that the customer's initial session is still in progress and to ignore referral information for the "new" session, add the utm_nooverride=1 parameter to your payment gateway success pages.

For example, for the page URL /checkout/payment/success, pass your gateway the following URL: /checkout/payment/success?utm_nooverride=1.

In your PHP code, the parameter should look like this: $this→_redirect('checkout/onepage/success', ['utm_nooverride' => '1']).

Make sure you do this for all links from the payment gateway to your site.

✅   Tip! Our ready-made integrations for Magento 1 and 2 do this automatically.

Server-side solutions

These solutions need a server environment and may require significant development effort.

📘 Note:

  • Server-side solutions are still in their infancy and could require regular adjustment and maintenance.
  • It is not possible to use client-side and server-side solutions at the same time.

How to send additional data

To send additional event data to Google Analytics, you can use Google's Measurement protocol .

To send additional information about a customer's journey, you can use notifications from our webhook. For example, that payment was successful or that the order was cancelled.

How to process data on your server

Instead of collecting data client side and sending it directly to Google Analytics, you can first send data to your server for further processing before forwarding to Google Analytics using Google Tag Manager server side tagging.

This provides several benefits:

  • It moves data processing from client side to server side, which reduces page load time.
  • If your server is hosted on a subdomain of your site, you collect customers' data yourself instead of a third party. This avoids conflicts with third-party cookies.
  • You can add additional event data from other sources like MultiSafepay's webhook notifications.

For more information, see Google Tag Manager - Server-side tagging .

How to follow customers between sessions

To follow a customer's journey between different sessions or browsers, in addition to using Google Tag Manager server-side tagging, you need to also update the data layer of your site to capture information that accurately identifies the customer. For more information, see Google Tag Manager - The data layer .



Email [email protected]

Top of page