Embedding Google Analytics and Conversion Tracking

Slate fully supports Google Analytics and other analytics platforms with Javascript APIs for registering page views and conversion events.

Tracking Code

Most analytics platforms include a snippet of Javascript code that can be embedded onto a page to register the page view.  These scripts set a persistent cookie that may be used to track the viewer from one webpage to another, and through browsing sessions.  Most analytics platforms will provide code that looks like the following Google Analytics tracking code:

<script>(function(i,s,o,g,r,a,m)
{i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){(i[r].q=i[r].q||
[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
m=s.getElementsByTagName(o)
[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)})
(window,document,'script','//www.google-
analytics.com/analytics.js','ga'); ga('create', 'UA-XXXXXX-XX', 'auto');
ga('send', 'pageview');</script>

 When evaluating the code for inclusion, first confirm that the code does not contain any calls to document.write.  If you see anything like document.write, you should avoid including this code, as this is likely old tracking code and is not intended to work with modern browsers and platforms.

Once you have prepared the tracking code, you can embed this code into the /shared/build.xslt template file, which can be edited through the File Editor by clicking on the file name.  You will want to place the code just above the </head> closing tag.  This will ensure that the script loads at the beginning of the page load, which may be necessary for conversion events later.

Tracking Code

Conversion Code

Many analytics platforms, including Google Analytics and Google AdWords, provide the capability to register "conversion events" based upon certain user actions.  These may include starting or submitting an application, submitting a request for information form, etc.  For example, you may have a Google AdWord that directs users to a landing page with a call to action to sign up onto your mailing list.  To gauge the efficacy of these advertisements, and to take advantage of Google AdWord's built-in optimization capabilities, you may want to embed specific conversion code based upon an event, such as signing up onto the mailing list.

First, you will need to create the conversion code.  In Google AdWords, you may receive code that looks like the following:

<script>
var google_conversion_id = 1234567890;
var google_conversion_language = "en";
var google_conversion_format = "3";
var google_conversion_color = "ffffff";
var google_conversion_label = "XXX";
var google_conversion_value = 1.000000;
var google_remarketing_only = false;
</script>
<script src="//www.googleadservices.com/pagead/conversion.js"></script>
Communications

Triggers

You will need to identify what within Slate should trigger this action.  If, for example, you want the conversion event to fire when a respondent submits a form, you can create a custom "Confirmation Page" onto which this code can be embedded.  

When you access the form through the administrative system in Slate, you can click the "Communications" button to retrieve the list of configured communications, including upon registration emails that may be sent.  If you want the same message to be emailed and shown in the browser, you can create or edit any existing "upon registration" communication.  You can also, if desired, create a custom "confirm page only" communication.  

Embedding the Code in Communications

Next, click the "Source" icon in the toolbar and paste the conversion code that you have.

communications example

You may receive a warning message about script tags when you add this code to your confirmation page. You can ignore this as long as your communication is set to "Confirmation Page Only," as the warning message is only relevant for email communications.

That's it!  Upon submitting the form, the confirmation page will be displayed and the conversion code will be loaded and executed.  These same techniques can be applied elsewhere throughout Slate, including in the online application, which is largely editable through the Application Editor.

Embedding the Code in the Form Description

You can also track when someone accesses the form, you can add the Facebook pixel code to the form's description, just before the closing </head> tag in the source code:

mceclip5.png

Was this article helpful?
3 out of 7 found this helpful