Using Google Tag Manager to Setup Conversion Tracking

Google Tag Manager is a tag management system that allows you to update tags and code snippets on your website or mobile app, such as those intended for traffic analysis or marketing optimization.

You can use Google Tag Manager to deploy the Oktopost tracking code on your website, without having to involve development, in a few simple steps.

Getting Started

If you already have a Google Tag Manager account you can go ahead and skip this step, otherwise lets begin by making sure that GTM is properly set up.

  1. Go to Google Tag Manager and create an account
  2. Create a container for your site
  3. Add the container snippet to your site

Once the account is set up the next step is to create a tag for the Oktopost tracking code.

Creating a Tag for Oktopost

A tag is a snippet of code that sends information to a third party, in this case Oktopost. By using GTM you can specify the tags that you want to fire and when do you want them to fire using the user interface.

Step 1: Inside of your site's container go to the Tags tab.

 

Step 2: Click on New to add a new tag.

 

Step 3: In the pop out window name your tag.

Step 4: Click on the Tag Configuration box and in the scroll down menu choose Custom HTML tag.

 

Step 5: Copy and paste the tracking code from your Oktopost Account Settings to the text box that appears. Make sure the code is placed within an opening and closing script tags.


Step 6: In order to make sure that the code is available on all pages click on the Triggering box and choose Fire on: All Pages.

 

Step 7: Click Create tag.

Step 8: Click Publish to implement the updates.

That's it! You can now go ahead and set up the conversion types in Oktopost according to your websites' definition of conversions. If your websites' conversions are triggered using JavaScript events, you will need to use Custom Events as described below.

Custom Events

Custom events allow you to trigger conversions in cases where your forms are submitted using JavaScript without redirecting the user to a destination page. To set up custom events you will need to:

  1. Create a trigger that fires based on a custom event
  2. Create a tag with the Oktopost conversion code that fires based on the trigger you've created
  3. Add the custom event to your JavaScript code whenever a form is submitted

Creating the trigger

A trigger is a condition that evaluates to either true or false. It is composed of one event and one or more filter (except in the case of a custom event which doesn't require a filter.) In GTM you define triggers to specify when tags should or shouldn't execute.

Step 1: Inside of your site's container go to the triggers tab.



 

Step 2: Click on New to add a new trigger.

 

Step 3: Name your trigger.

Step 4: Click on the Trigger Configuration box and then in the drop down menu select Custom Event.

 

Step 5: In Fire on write the name of the custom event you created, e.g. formSubmission.

 

Step 6: Create Trigger.

Next you need to set up the tag.

Creating the tag

Step 1: Inside of your site's container go to the tags tab.

Step 2: Click on New to add a new tag.

Step 3: Name your tag.

Step 4: Choose Custom HTML tag.

Step 5: Inside the text box that appears copy and paste the following code:

_oktrk('send', {
	tag: 'YOUR TAG NAME'
});

Step 6: Next click on the Triggering box and in the list select the trigger that you have created previously.

 

Step 8: Click Save.

Step 9: Click Publish to update all changes.

Add the custom event code to your website

Add the snippet below to the JavaScript code used to submit the form on your website. If you're unsure about how or where to place it, you should probably consult with your webmaster or contact us.

dataLayer.push({'event':'formSubmission'});

A data layer is an object that contains all of the information that you want to pass to GTM. In this case you want to add (push) an object type event the trigger will respond to.

Feedback and Knowledge Base