UTM Tracking With Multiple Marketo Instances

July 27, 2020 Jon Bourne

Most Marketo customers have only one Marketo instance, or perhaps two if they also get a sandbox for testing or development work. There are occasions, though, when we encounter multiple production Marketo instances, often in scenarios where companies were acquired or merged. And for some clients, it makes sense to continue using all of these instances in parallel with one another. In this article, we’ll explore how to send UTM data to different fields through different Marketo forms to different Marketo instances.

One of our clients has three production Marketo instances. (We won’t go into the reasons; suffice it to say that it makes sense for their business.) This client uses Marketo forms on their website from each of the three instances. The custom fields in each instance for storing UTM data are different. This means that these UTM fields’ SOAP API names, which Marketo forms use, are also different. Depending on which instance a given form POSTs to, the corresponding UTM fields need to be used.

But this presents a conundrum for the marketing team: how do we map data from a normalized UTM query string to instance-specific UTM fields to store that data? Considering that this field mapping can change on a per-page basis across the same website, depending on which form is used, the Marketo instance represented on the page needs to be detected on the fly to append the UTM data into hidden fields that correctly mapped to that instance’s UTM fields.

Our standard UTM tracking script provided the basis for a solution. The fundamental difference between its standard functionality and an optimal solution for this particular client is that the script only provides mapping of UTM parameters to one Marketo instance’s UTM fields. (That is the most common scenario, so it makes sense for that to be the default approach.) To add the flexibility needed to make this script work for this particular client required a per-instance mapping of UTM data to instance-specific Marketo fields, and that mapping needed to happen in real-time depending on which Marketo form is loaded on whichever page the visitor visits.

To understand the solution, one must first understand Munchkin IDs, which look something like ABC-123-XYZ. These IDs uniquely identify each Marketo instance: no two instances share a Munchkin ID. Combine this handy little unique data point with the fact that each Marketo form also includes its corresponding Munchkin ID, and we suddenly have all the necessary ingredients to create additional instance-specific functionality within the UTM tracking script.

The first step to supporting this dynamic UTM field mapping involved creating a data structure to group these UTM (and GCLID) fields by Munchkin ID.

  • ABC-123-XYZ
    • [UTM fields]
  • DEF-456-XYZ
    • [UTM fields]
  • GHI-789-XYZ
    • [UTM fields]

Within these Munchkin-specific groups of fields were two subdivisions: one set of fields for the original or first UTM values and another for the latest UTM values—effectively, first touch and last touch. These align with the two cookies that the script creates—dpi_utmOrigVals and dpi_utmVals.

  • ABC-123-XYZ
    • dpi_utmOrigVals
      • [UTM fields]
    • dpi_utmVals
      • [UTM fields]
  • DEF-456-XYZ
    • dpi_utmOrigVals
      • [UTM fields]
    • dpi_utmVals
      • [UTM fields]
    • GHI-789-XYZ
      • dpi_utmOrigVals
        • [UTM fields]
      • dpi_utmVals
        • [UTM fields]

Here’s what the data structure looks like in code.

Digital Pi UTM Tracking

Once this data structure existed, the next step was to abstract the field mapping from being hard-coded into the tracking cookies. This meant updating the script to store the UTM data in the cookies with its original parameter names rather than the Marketo fields.

 

Next, we needed to detect whether a Marketo form was present on the page and, from it, extract its corresponding Munchkin ID from the munchkinId hidden field. This is made quite simple by the MktoForms2 API.

 

Finally, when cookie data is present and a Marketo form is detected on the page, we use the munchkinId from the Marketo forms API to complete the mapping and add instance-specific hidden fields to the form, with values coming directly from the stored cookies.

For each value found in these two UTM tracking cookies:

  • Select the correct Marketo instance from the utmFieldMapping list by Munchkin ID
  • Select the field group that corresponds to the cookie name
  • Select the hidden field name from the corresponding cookie attributes
  • Populate the hidden fields from the corresponding cookie values

The end result is Marketo instance-specific hidden fields on Marketo forms populated with UTM data from persistent UTM tracking cookies.

About the Author

Jon Bourne

Jon is a full-stack marketer and Marketo consultant. He loves marketing, technology, people, and solving problems. Jon helps other marketers define the outcomes they want, and do whatever it takes to help them achieve their goals.

Follow on Linkedin More Content by Jon Bourne
Previous Article
Summer of Scale, Global Scale!
Summer of Scale, Global Scale!

Digital Pi kicks off new summer series about doing more with less using the Gold Standard framework. A soli...

Next Article
Marketo Security Cannot Be An Afterthought
Marketo Security Cannot Be An Afterthought

Digital Pi takes on Marketo security