Skip to main content
knowledgecenter.2checkout.com

Google Tag Manager Code Integration

What is Google Tag Manager (GTM)?

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 Analytics or third-parties. For more information on the Google Tag Manager and how to install it, click here.

GTM Implementation

To implement Google Tag Manager on your website:

  1. In cPanel → Setup → Interface templates, click to edit the template that needs to be tracked. An example is shown in the image below:

template edit snap.png

2. 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. An example of the Google Tag Manager code is shown below:

code sample.png

The GTM code needs to be placed on your own website as well – one snippet of code in the <head> and the other in the <body> tag, if this step has not already been done previously. See the image below for a screenshot of an example code that needs to be added to your own website. More information can be found on this page: https://developers.google.com/tag-manager/quickstart.

installGTM.png

Sending MyOrder Data to Google Analytics

A JavaScript object called myOrder is available on the ‘Thank you’ page and provides information about the purchased products including ID, quantity, name, price etc. To see the information on orders in Google Analytics, add a code snippet (for example add <div></div>) to the Tracking Script Content section in your vendor cPanel (https://secure.2checkout.com/cpanel/tracking_script.php), and apply the code to all languages or to the languages for which you want your template to be tracked, as shown in the images below.

tracking script.png

tracking script content.png

Google Tag Manager Configuration

1. How to configure Google Tag Manager for your own website

1.1 The Google Analytics universal tag for your own website (ex. www.mywebsite.com) should look as shown in the below image.

GAtag.png

This Google Analytics tag for your own website must have Page View selected as Track Type.

tagconfig.png

1.2 The variable for the Google Analytics tag should be configured as follows: in the Tracking ID section in the Google Analytics Settings area, add the tracking ID of your own Google Analytics property.

#Tip: If you don’t know the Google Analytics property ID, you can find it here.

GA settings.png

If you use your own custom domain for the shopping cart, then proceed to step 1.4.

If you use the 2checkout shopping cart (secure.2checkout.com), further implementation for the cross-domain tracking is needed. In this case, you (vendor) need to proceed to step 1.2 to count the visitors that first go to your website, and then to secure.2checkout.com as the same visitors in Google Analytics.

1.3 If you need further implementation for the cross-domain tracking, follow the additional setup needed for the Google Analytics variable. In the More Settings section, under Fields to set, click Add Field. You will see two fields that need to be filled in.  In the first field, enter “cookieDomain” as Field Name, and “auto” as Value. In the second field, enter “allowLinker” as Field Name, and “true” as value. In the section Cross Domain Tracking, in the field Auto Link Domains, enter “secure.2checkout.com” and in the Use Hash as Delimiter field enter “False”, and in the Decorate Forms enter “True”.

adfield.png

1.4 The triggering for this tag is All Pages.

triggering.png

2. Implementing Google Analytics with Google Tag Manager for 2Checkout

2.1 Besides the Google Analytics tag for your own website, create a GA tag for 2Checkout, as shown in the image below.

tags.png

2.2 Name this new tag “2Checkout Google Analytics” to differentiate it from your own Google Analytics website tag. Select Event as Track Type and 2Checkout as Category. Select Google Analytics Settings and click Enable overriding settings in this tag.

2checkout GA settings.png

2.3 Under More Settings, select True for Ecommerce and click Use Data Layer. As Tag Firing Options select Once per event, as shown in the below image.

selectUsedataLayer.png

2.4 In the Trigger Configuration area, create a trigger named 2Checkout Event, with a Custom Event trigger type. Write 2Checkout event in the Event name field and select All Custom Events for when to fire the trigger, as indicated in the following image.

2checkout events.png

2.5 The last step is to Save and Publish all the changes made.