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)
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.

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 :
<!-- 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:
<!-- 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

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.
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.

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.
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.

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.

Google Tag Manager Configuration
How to configure Google Tag Manager for your own website
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.


The variable for this tag should include your Google Universal Analytics Tracking ID in the Google Universal Analytics Settings (Tracking ID).
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

Implementing Google Universal Analytics with Google Tag Manager for 2Checkout
Create a Google Universal Analytics tag for 2Checkout
Besides the tag for your own website, create a Google Universal Analytics tag for 2Checkout.

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.

Hint
Last updated
Was this helpful?


