For the complete documentation index, see llms.txt. This page is also available as Markdown.

Google Tag Manager Code Integration for Default Flows – Universal Analytics

Overview

The Google Tag Manager (GTM) is a small piece of JavaScript and non-JavaScript code (a container snippet) that you paste into your pages to configure or enable tags from Google Universal Analytics or third parties. For more information on the Google Tag Manager and how to install it, click here: https://support.google.com/tagmanager/answer/6102821?hl=en&ref_topic=3441530

This documentation refers to Google Universal Analytics, which is a deprecated version that will be sunset starting July 1st 2023 for free Universal Analytics properties and starting July 1st 2024 for 360 Universal Analytics properties. We strongly recommend you to migrate to Google Analytics 4 as soon as possible.

Setting the Google Tag Manager (GTM)

1

Install GTM in your 2Checkout Merchant Control Panel template

  • Log into your 2Checkout Merchant Control Panel: https://secure.2checkout.com/cpanel

  • Navigate to Setup → Interface templates.

  • Click Edit on the template that needs to be tracked.

web analytics in Merchant Control Panel_4.png
  • In the Head Information area → Meta & CSS, paste the Google Tag Manager code for your account at the end of the existing code in the section. Example GTM script to add in the :

GTM (head) - example
<!-- Google Tag Manager -->
<script>(function(w,d,s,l,i){w[l]=w[l]||[];w[l].push({'gtm.start':
new Date().getTime(),event:'gtm.js'});var f=d.getElementsByTagName(s)[0],
j=d.createElement(s),dl=l!='dataLayer'?'&l='+l:'';j.async=true;j.src=
'https://www.googletagmanager.com/gtm.js?id='+i+dl;f.parentNode.insertBefore(j,f);
})(window,document,'script','dataLayer','GTM-XXXXXX');</script>
<!-- End Google Tag Manager -->
  • Example GTM code for the tag:

GTM (body) - example
<!-- Google Tag Manager (noscript) -->
<noscript><iframe src="https://www.googletagmanager.com/ns.html?id=GTM-XXXXXX"
height="0" width="0" style="display:none;visibility:hidden"></iframe></noscript>
<!-- End Google Tag Manager (noscript) -->
  • The GTM code also needs to be placed on your own website — one snippet in the and the other in the tag (if not already present). More info: https://developers.google.com/tag-manager/quickstart

Install GTM

Sending MyOrder Data to Google Universal Analytics

By default, the myOrder object is available only for orders with payments authorized instantly (e.g., credit cards and PayPal) after the payment is complete. To have the myOrder object available for all placed orders regardless of payment status (so you can send revenue to Google Universal Analytics based on myOrder.TotalPrice, including more offline payment methods), follow the steps below.

1

Enable Show message for all placed orders

  • Log in to your Merchant Control Panel account: https://secure.2checkout.com/cpanel

  • Go to Setup → Ordering Options: https://secure.2checkout.com/cpanel/order_settings.php

  • Scroll down to the After sale message area and check the checkbox for Show message for all placed orders.

web analytics in Merchant Control Panel_2.png
  • Click Save settings at the bottom of the page.

A JavaScript object called myOrder is available on the “Thank you” page providing information about purchased products including ID, quantity, name, price, etc.

2

Add tracking script in Merchant Control Panel

  • Log in to your Merchant Control Panel: https://secure.2checkout.com/cpanel

  • Navigate to Setup → Ordering Options and click on the Analytics tab.

web analytics in Merchant Control Panel_1.png
  • Scroll down to the Tracking script section (https://secure.2checkout.com/cpanel/web_analytics.php) and add a code snippet (for example add).

  • Apply the code to all languages or to the languages for which you want your template to be tracked.

  • Click Save at the bottom of the page.

web analytics in Merchant Control Panel_3.png

Google Tag Manager Configuration

How to configure Google Tag Manager for your own website

1

Configure the Google Universal Analytics tag for your website

  • Create a Google Analytics - Universal Analytics tag for your website (example: www.mywebsite.com). The tag should have Track Type set to Page View.

GAtag.png
tagconfig.png
  • The variable for this tag should include your Google Universal Analytics Tracking ID in the Google Universal Analytics Settings (Tracking ID).

2

Cross-domain tracking (if needed)

If you use your own custom domain for the shopping cart, you can stop here. If you use the 2Checkout shopping cart (secure.2checkout.com), further implementation for cross-domain tracking is needed so visitors are counted as the same in Google Analytics.

  • In the Google Universal Analytics variable, open More Settings → Fields to set → Add Field.

    • Field Name: cookieDomain, Value: auto

    • Field Name: allowLinker, Value: true

  • In Cross Domain Tracking:

    • Auto Link Domains: secure.2checkout.com

    • Use Hash as Delimiter: False

    • Decorate Forms: True

adfield.png
3

Triggering

  • Set the triggering for this tag to All Pages.

triggering.png

Implementing Google Universal Analytics with Google Tag Manager for 2Checkout

1

Create a Google Universal Analytics tag for 2Checkout

  • Besides the tag for your own website, create a Google Universal Analytics tag for 2Checkout.

tags.png
  • Name this tag “2Checkout Google Analytics” to differentiate it from your own site tag. Select Event as Track Type and set Category to 2Checkout.

  • Select Google Analytics - Universal Analytics Settings and click Enable overriding settings in this tag.

2checkout GA settings.png
2

Enable Ecommerce and use the data layer

  • Under More Settings, set Ecommerce to True and click Use Data Layer.

  • For Tag Firing Options select Once per event.

selectUsedataLayer.png
3

Create trigger for 2Checkout events

  • In Trigger Configuration create a trigger named 2Checkout Event with Custom Event trigger type.

  • In Event name enter: 2checkout event (case sensitive).

  • Select All Custom Events for when to fire the trigger.

2checkout events.png
4

Save and publish

  • Save and Publish all changes made in Google Tag Manager.

Hint

If you don’t know the Google Universal Analytics property ID, you can find it here: https://support.google.com/analytics/answer/1008080?hl=en

Last updated

Was this helpful?