MarinTracker Asynchronous JavaScript Integration Guide

Introduction

This guide documents the steps necessary to integrate conversions and revenue using Marin Tracker JavaScript. Marin will work with the customer during scoping and configuration process to document the specifics regarding:

  • Conversion Types and Attribution settings.
  • Asynchronous JavaScript Click code.
  • Asynchronous JavaScript Conversion code.
  • Current URL structure and proposed modifications to accommodate tracking parameters.
  • The options for handling Google Sitelinks.
  • Implementation Process and Checklist

About The Tracker JavaScript Code

Marin's Asynchronous JavaScript click and conversion capture code snippets record incoming traffic and conversions from paid search. This code can also be used to show conversion relationships (called "paths") between paid search and other media channels such as affiliate marketing, online display campaigns and natural search. The asynchronous nature of the code means the pixel is built in the background, and will not affect page load speed.

  • JavaScript will be placed on the customer's website(s).
  • Confirmation pages will require a change to the server-side page generation code in order to include details about the transaction.
  • URLs must be tagged at the keyword or creative level with Marin's tracking parameters.
  • Marin Tracking numbers will be validated by Customer and Marin Professional Services to ensure accuracy. Despite this, there may be differences between different tracking methodologies based on attribution rules, page placement, etc. 90% accuracy is typically considered a good match but the number could be lower for valid reasons.

Click Capture Code

What does this code do: The javascript will log the keyword and creative that brought the visitor to your site, based on, but not limited to, the keyword ID and creative ID which are embedded in the paid click destination URL. The Javascript will capture the referring URL, Destination URL, and set a Cookie ID (UUID) in the user’s browser then send all three values to Marin. This Click data will be joined with Conversion data in order to attribute conversions to a keyword or creative. In the unlikely event that JavaScript is disabled in the browser the <noscript> image pixel will fire, but will not contain any tracking data, it is used for auditing purposes only.

Where to place the code: The following javascript code snippet is to be exposed on all landing pages of the website, ideally by being placed in a global template such as a footer template.

Field Values: (provided by your onboarding team)

  • [CLIENT-TRACKING-ID] = (required) Static Alphanumeric String, unique to each Marin client account.

Please note the code in this section is only an example and should not be placed on the customer's landing pages.

<!-- BEGIN: Marin Software Tracking Script -→
   
     <script type="text/javascript">
    var _mTrack = _mTrack || [];
    _mTrack.push(['trackPage']);
    
    (function() {
    var mClientId = '[CLIENT-TRACKING-ID]';
    var mProto = ('https:' == document.location.protocol ? 'https://' : 'http://');
    var mHost = 'tracker.marinsm.com';
    var mt = document.createElement('script'); mt.type = 'text/javascript'; mt.async = true; mt.src = mProto + mHost + '/tracker/async/' + mClientId + '.js';
    var fscr = document.getElementsByTagName('script')[0]; fscr.parentNode.insertBefore(mt, fscr);
    })();
    </script>
    <noscript>
    <img src="https://tracker.marinsm.com/tp?act=1&cid=[CLIENT-TRACKING-ID]&script=no" >
    </noscript>
   
<!-- END: Copyright Marin Software -→

Conversion Type Settings

Marin will work with the customer during scoping and Integration Plan development to define their conversion types in the following table:

Conversion Type Conversion ID Conversion Source Use for Bidding? Many or 1 Per Click? Attribution Date
Example: Sale Sale Marin Tracker yes many Click/Conv Date
Example: Lead Lead Marin Tracker no many Click/Conv Date

Where:

  • Conversion Type: The conversion type name as it should appear in the Marin interface.
  • Conversion Type ID: The conversion type id as it should be passed in the Marin conversion code.
  • Conversion Source: Marin Tracker JavaScript.
  • Use for Bidding: Yes or No to indicate if the conversion type should be used for bidding.
  • Revenue: Yes or No to indicate if the conversion type passes revenue.
  • Many or 1 Per Click: Indicates how Marin should attribute conversions.
  • Attribution: Date of Click and Date of Conversion.

Marin Software cannot effectively bid against user engagement metrics like pageviews, bounces, time on site, and other non-transactional conversion information. During the Integration Plan review call customer will to confirm conversion types, # Conversions per Click, and Method of Attribution (Date of Click versus Date of Conversion or both.

Conversion Capture Code

What does this code do: The Javascript will take the values specified below in the array of conversion metrics and send them to Marin along with the Cookie ID (UUID) created by the Click JavaScript; this allows Marin to join Clicks and Conversion data together. The client’s development team is responsible for inserting the appropriate conversion data into the fields specified below, using server-side logic. The fields below are defined in a JSON Array as a name-value pair; field values are defined below the code snippet. In the unlikely event that JavaScript is disabled in the browser the <noscript> image pixel will fire, but will not contain any tracking data, it is used for auditing purposes only. 
Where to place the code: The following javascript code snippet should be placed on the Conversion Success Page (thank you page). If using an On-Click Event to track Conversion events please consult with your Marin onboarding team first.

Please note the code in this section is only an example and should not be placed on the customer's conversion pages.

<!-- BEGIN: Marin Software Tracking Script -→
    <script type="text/javascript">
     var _mTrack = _mTrack || [];
     
     _mTrack.push(['addTrans', {
     currency :'<ISO-CURRENCY-CODE>',
    items : [
     {
     orderId : '<ORDER-ID>',
    convType : '<CONV-TYPE-ID>',
     product : '<PRODUCT-SKU/NAME>',
     price : '<PRICE>',
    category : '<CATEGORY>',
    quantity : ‘<QUANTITY>’
    }
    ]
     }]);
     
    _mTrack.push(['processOrders']);
    (function() {
     var mClientId = '[CLIENT-TRACKING-ID]';
    var mProto = ('https:' == document.location.protocol ? 'https://' : 'http://');
     var mHost = 'tracker.marinsm.com';
     var mt = document.createElement('script'); mt.type = 'text/javascript'; mt.async = true; mt.src = mProto + mHost + '/tracker/async/' + mClientId + '.js';
    var fscr = document.getElementsByTagName('script')[0]; fscr.parentNode.insertBefore(mt, fscr);
     })();
     
    </script>
    <noscript>
    <img src="https://tracker.marinsm.com/tp?act=2&cid=[CLIENT-TRACKING-ID]&script=no" >
    </noscript>
   
<!-- END: Copyright Marin Software -→

Field Values:

Field Name Definition Source Required
[CLIENT-TRACKING-ID] Static Alphanumeric value, unique to each Marin Client Account, provided by your PS Onboarding Team Marin Required
<ISO-CURRENCY-CODE> The ISO Currency Code is a 3 digital value that presents the currency for a specific country. Insert ISO code if currency for this transaction is different from the Client Accounts default currency type, else remove the placeholder and leave blank. 
Examples: USD, JPY, GBP, AUD. 
Link to ISO Currency Codes: http://en.wikipedia.org/wiki/ISO_4217
Client Optional
<ORDER-ID>

The conversion event’s unique identifier which can be used in reporting as well as de-duping, in case of a page reload. It is very important the Order-ID is not recycled at any time as the ID will be used for de-duplication. If an order-ID is not available please remove the placeholder and leave blank.

This value should be the same in all instances where you are replacing the <ORDER-ID> placeholder.

Client Optional
<CONV-TYPE-ID> The conversion type ID is defined in the Conversion Types Section of the Integration Plan, and corresponds to the Conversion Event. 
Please note that the ID is CASE SENSITIVE
Marin Required
<PRODUCT-SKU/NAME> This field can be used to pass Marin information about the product or transaction, else remove the placeholder and leave blank. 
Note: This value can only be accessed from Custom Reports in Marin.
Client Optional
<CATEGORY> This field can be used to pass Marin information about the product category or other transaction information, else remove the placeholder and leave blank. Note: This value can only be accessed from Custom Reports in Marin. Client Optional
<PRICE>* Price per Item/transaction. Marin will multiply <PRICE> X <QUANTITY> to get the TOTAL value, in the App. If no revenue, remove placeholder and leave blank. Example: 30.20 (Decimal value only, do not include symbols) Client Optional
<QUANTITY> The number of items purchased in this transaction. 
Example: 5 (Integer Value, if blank, DEFAULT = 1)
Client Optional

*<Price> X <Quantity> clarification: When a user converts via a single action which triggers Marin Tracker, the pixel picks up granular data per item's quantity. So if a user buys 3 pairs of shoes for 50 each, a pair of gloves for 20 and 2 shirts for 10, the Javascript pixel will parse those out as "50|20|10" for price, and "3|1|2" for quantity. Each of those will be mapped to each other and multiplied to get the total revenue, which will be "190" (50x3 + 30x1 + 20x2)

URL Structure

In order for Marin to track using Tracker to attribute conversions/revenue, each keyword, creative, and placement URL must be tagged with a unique identifier (ID). We are recommending the following URL structure where the highlights represent the required Marin variables:

 (Google Keyword Example) 
http://www.domain.com/path/landingPage.html?mkwid=[distribution][uniq_id]&pcrid=[creative_id]&pkw=[keyword_text]&pmt=[matchtype]&pdv=[device]

The following table illustrates the values which will be substituted using when using Marin variable insertion.

Insertion Variable Function Google 
Resulting Value
Microsoft 
Resulting Value
FaceBook 
Resulting Value
[uniq_id] Inserts an 8 character unique alpha-numeric ID 8 character unique ID 8 character unique ID 8 character unique ID
[distribution] Inserts the dynamic publisher parameter for click source {ifsearch:s}{ifcontent:c}    
[device] Inserts a single digit character for device type: [c, m ,t] if available. {device}    
[creative_id] Inserts the dynamic insertion parameter for creative id {creative} {Adid}  
[keyword_text] Inserts the dynamic insertion parameter for keyword {keyword} {keyword}  
[matchtype] Inserts the dynamic insertion parameter for matchtype {Matchtype} {Matchtype}  

The following lead parameters should be included for the given publisher where an “X” is present. The {device} value will either be placed within the MKWID parameter or in the PDV parameter, not both. 

Parameter Name Insertion Variable Google Microsoft FaceBook
mkwid [uniq_id] X X X
mkwid [distribution] X X  
mkwid [device] X    
pcrid [creative_id] X X  
pkw [keyword_text] X X  
pmt [matchtype] X X  
pdv [device] X    
Creative URL Variables   Same as Above {param1} Same as Above

URL Builder And ID Parser Settings

The following settings under keyword ID parsing will need to be configured in the Marin application:

Parameter Start after these sequences Stop after these Sequences
Tracking ID mkwid &
{Creative} Parameter pcrid &
Keyword pkw &
Matchtype pmt &
Device Type Appended? Device Delimiter
NO Pipe (“|”) OR Underscore (“_”)

The following settings will be enabled for the client in the Marin URL Builder:

Publisher Populated Keyword Level URL
  mkwid=[distribution][uniq_id]&pcrid=[creative_id]&pkw=[keyword_text]&pmt=[matchtype]&pdv=[device]
  mkwid=[distribution][uniq_id]&pcrid=[creative_id]&pkw=[keyword_text]&pmt=[matchtype]
  mkwid=[uniq_id]
Auto URL Correction Settings  
Auto URL Correction Warn (Professional Services will enable immediately following the initial URL tagging process if applicable).
Auto Build URLs on Creative On
Auto Build URLs on Placements On

Marin supports two methods for tracking Google sitelink performance. Please note that only one option may be selected.

Option 1:

Marin can attribute revenue to the keyword that triggered the sitelink. This allows you to appropriately bid on keywords since you know the true ROI of the keyword. The disadvantage of this is that you do not know which sitelink triggered the conversion.

In order for conversion/revenue data from sitelinks to be properly attributed to the driving keyword, each Google Sitelink is appended with the following {copy} parameters:

&{copy:mkwid}&pcrid={creative}&pkw={keyword}&pmt={matchtype}&pdv={device} 

Option 2:

If you wish to attribute conversions directly to the sitelink to track individual sitelink performance, then placeholder keywords are created in Marin for proper tracking. Even though this allows you to see what sitelink triggered the conversion, you do not know which keyword triggered the conversion. Additionally, this method makes keywords appear as though they are not driving as many conversions as Google attributes the click to the actual keyword, which may affect bidding.

Placeholder keywords are set up for each Google Sitelink and the URLs generated in Marin need to be copied over to the actual Sitelink in Google.

Implementation Check List

Step Task Owner Dependencies
1 Review and finalize Integration Plan Client/Marin  
2 Setup URL Builder and Parser Settings Marin 1
3 Deploy JavaScript click and conversion capture code Client 1
4 Setup Conversion Types   1
5 Build URLs, QA and traffic to publishers Marin/Client 2
6 QA 3 days of conversion/revenue data Marin/Client 3,4,5
7 Transition to Client Services Team Marin 6

Use Cases

Example 1: Multiple Conversion Types In A Single Conversion Event

The Example below illustrates how multiple conversion types are captured. Because the Conversion Event is referencing more than one conversion type, it is important to ensure that the ORDER ID in unique per conversion type instance. Marin recommends the following setup options, in order of preference:

Option 1: Change the OrderID field to concatenate the conversion type ID to the Order ID. Ex: “[order-id]-[conv-type id]” 
Option 2: If option 1 is not possible please leave the OrderID field BLANK

<!-- BEGIN: Marin Software Tracking Script -->

<script type="text/javascript">
 var _mTrack = _mTrack || [];
 
 _mTrack.push(['addTrans', {
 currency : 'USD',
 items : [

User signs up for a membership, valued at $20.00

{
orderId : '123456-subscription',
convType : 'subscription',
product : 'membership signup',
price : '20.00',
quantity : ‘1’
 },
 {

User also upgrades membership to gold level, valued at $10.00

orderId : '123456-upgrade_gold',
convType : 'upgrade_gold',
product : 'membership upgrade (gold)',
price : '10.00',
quantity : ‘1’
 }
 ]
 }]);

_mTrack.push(['processOrders']);
 (function() {
 var mClientId = '1a2b3c4d';
 var mProto = ('https:' == document.location.protocol ? 'https://' : 'http://');
 var mHost = 'tracker.marinsm.com';
 var mt = document.createElement('script'); mt.type = 'text/javascript'; mt.async = true; mt.src = mProto + mHost + '/tracker/async/' + mClientId + '.js';
 var fscr = document.getElementsByTagName('script')[0]; fscr.parentNode.insertBefore(mt, fscr);
 })();
</script>
<noscript>
<img src="https://tracker.marinsm.com/tp?act=2...3c4d&script=no" >
</noscript>
<!-- END: Copyright Marin Software -->

Example 2: Tracking To A Single Conversion Type (Leads)

The Example below illustrates how a single conversion type is captured.

<!-- BEGIN: Marin Software Tracking Script -→

<script type="text/javascript">
 var _mTrack = _mTrack || [];

_mTrack.push(['addTrans', {
 items : [{
 orderId : '300188403',
 convType : ‘store_locator’
 }]
}]);

 _mTrack.push(['processOrders']);
 (function() {
 var mClientId = '1a2b3c4d';
 var mProto = ('https:' == document.location.protocol ? 'https://' : 'http://');
 var mHost = 'tracker.marinsm.com';
 var mt = document.createElement('script'); mt.type = 'text/javascript'; mt.async = true; mt.src = mProto + mHost + '/tracker/async/' + mClientId + '.js';
 var fscr = document.getElementsByTagName('script')[0]; fscr.parentNode.insertBefore(mt, fscr);
 })();
</script>
<noscript>
<img src="https://tracker.marinsm.com/tp?act=2...3c4d&script=no" >
</noscript>

<!-- END: Copyright Marin Software -->

Example 3: Tracking A Single Conversion Type, With Multiple Items (Order Basket)

The Example below illustrates how a single conversion type is captured.

<!-- BEGIN: Marin Software Tracking Script -→

<script type="text/javascript">
 var _mTrack = _mTrack || [];

 _mTrack.push(['addTrans', {
 currency : 'USD',
 items : [
 {

Item 1: Running Shoes Valued at $120.00 X 1 (quantity) = $120.00 in Marin

orderId : '123456',
 convType : 'sale',
 product : 'mens running shoes', 
 price : '120.00',
 quantity : ‘1’
 },
 {

Item 2: Running Socks Valued at $10.00 X 5 (quantity) = $50.00 in Marin

orderId : '123456',
 convType : 'sale',
 product : 'mens running socks',
 price : '10.00',
 quantity : ‘5’
 }
 ]
 }]);

 _mTrack.push(['processOrders']);
 (function() {
 var mClientId = '1a2b3c4d';
 var mProto = ('https:' == document.location.protocol ? 'https://' : 'http://');
 var mHost = 'tracker.marinsm.com';
 var mt = document.createElement('script'); mt.type = 'text/javascript'; mt.async = true; mt.src = mProto + mHost + '/tracker/async/' + mClientId + '.js';
 var fscr = document.getElementsByTagName('script')[0]; fscr.parentNode.insertBefore(mt, fscr);
 })();
</script>
<noscript>
<img src="https://tracker.marinsm.com/tp?act=2...3c4d&script=no" >
</noscript>

Written by Marketing @ Marin Software

Last published at: June 4th, 2023