Marketo UTM Tracking & Automation

Take the first step towards becoming an attribution master by learning how to set up Marketo UTM tracking programs and smart campaigns to match website visitors to particular ad campaigns, set first and latest touch attribution fields, and track downstream conversions to signup or contact sales forms.

This post will focus on tracking UTM parameters but if you want to learn how to track organic referral, social, and search visits with your Marketo campaigns so they DON’T STEAL ATTRIBUTION FROM YOUR PAID CAMPAIGNS then take a look at the Marketo Anonymous Leads & Attribution and A Centralized Marketo Attribution Model posts.

As a bonus for the eager beavers among us, I will also show you how you can streamline the process from a marketing team member requesting UTM parameters all the way to setting up tracking for these parameters in Marketo.

Marketo UTM Tracking & Automation Walkthrough Video

Tracking UTMs in Marketo

Marketo UTM Tracking Program

View of the Marketo UTM Tracking program from the nagivation tree
Marketo UTM Tracking Program

Within the Marketo UTM Tracking program there are 4 different smart campaigns responsible for tracking visits or conversions and moving a person to the appropriate status in the program. Moving people to these program statuses is important because this allows us to report on cost per lead and cost per success within Marketo.

The “Marketo UTM Tracking Campaign” and “Marketo Conversion Tracking Campaigns” sections below detail the setup of the 01 Visit, 02 Contacted, and 02 Converted smart campaigns. The setup of the 03 Anonymous smart campaign is detailed in the Marketo Anonymous Leads & Attribution Tracking post.

The first step when creating a Marketo UTM tracking program is to create a “Default” program type and set the “Channel” to your paid advertising or attribution channel. In this example the “PPC” channel is being used which has the “Visited” status to track anyone who visits our website from an ad campaign and the “Converted” or “Contacted” status to track anyone who signs up or contacts sales straight from the ad campaign.

Marketo advertising channel statuses
Marketo advertising channel statuses

The 01 Visit campaign, uses local program tokens within its flow steps to update attribution fields to these token values. Since these token values can be populated using the Marketo API (see the “Preparing Marketo UTM Tracking Smart Campaigns” section below) this means that the values the attribution fields will be set to can indirectly be changed by the API.

Marketo UTM Tracking Program Local Tokens
Marketo UTM Tracking Program Local Tokens

If you want to see possible values that the lead_source, lead_source_detail, source, medium, and campaign tokens can have then check out the Key tab of the “UTM Builder” sheet. To see how these tokens are used in the “Change Data Value” flow steps then read on!

Marketo UTM Tracking Campaign

Marketo UTM tracking is achieved by using 2 “Visits Web Page” triggers along with the “Querystring” and “Referrer” constraints to ensure that only web page visits with the desired UTM parameters matching our ad campaign are tracked.

Having the second “Visits Web Page” trigger with the “Referrer” constraint adds some redundancy because I have seen cases where the initial page visit with populated querystring parameters is missed but then the subsequent page view captures this information in the “Referrer” field.

Marketo UTM Tracking Campaign "Visits Web Page" triggers
Marketo UTM Tracking Campaign Trigger

N.B. The reason we are using local program tokens in the Change Data Value flow steps shown below instead of typing the desired values directly is that local program tokens facilitate the automatic creation of these UTM tracking programs via the Marketo API. Using the Marketo API it is not possible to update flow steps and so the only way we can create a new UTM tracking visit smart campaign and have the flow steps updated to set new attribution values is by using local program tokens in the flow steps and then updating these tokens via API (see the “Preparing Marketo UTM Tracking Smart Campaigns” section below).

Then the flow kicks off to:

  1. Change the person’s program status to “Visited”
  2. Set the person’s Latest Touch field to the UTM querystring using the {{my.utm}} token. This Latest Touch field will be used in the conversion campaigns below to see if this ad campaign was the last thing the person interacted with before signing up or contacting sales.
  3. If the person’s Person Source field is empty then update the Person Source and Lead Source Detail fields to be the {{my.lead_source}} and {{my.lead_source_detail}} tokens respectively. These are a person’s first touch attribution fields that can be used for attribution reporting later on.
Updating the program status, latest touch, and first touch attribution fields using "Change Data Value" flow steps
Updating the program status, latest touch, and first touch attribution fields

4. Update the utm_source, utm_medium, and utm_campaign fields to each of the corresponding UTM parameters. These 3 fields are supplemental to the Person Source and Lead Source Detail fields to provide more information, the utm_campaign field especially, about where a lead came from. The utm_source and utm_medium fields can be removed if desired, since their information is already contained in the Person Source and Lead Source Detail fields.

Storing the UTM parameters in their respective fields using "Change Data Value" flow steps
Storing the UTM parameters in their respective fields

5. If the person’s Acquisition Program is empty then set the Acquisition Program to the parent program of this smart campaign and the Acquisition Date to the {{system.dateTime}} token. Setting these 2 fields is the most important requirement for doing program performance and attribution reporting in Marketo.

Setting the Acquisition Program and Date in Marketo using "Change Data Value" flow steps
Setting the Acquisition Program and Date in Marketo

Marketo Conversion Tracking Campaigns

Remember that “Lastest Touch” field we set in the Marketo UTM tracking campaign flow above? Well whenever we get a person who signs up or contacts sales with this “Lastest Touch” field equal to the UTM querystring of our ad campaign then we know this ad campaign was the last thing they interacted with before carrying out these actions.

This is achieved by including the Lastest Touch = UTM Querystring as a filter along with the triggers and other filters mentioned below.

  • A Contact Sales Conversion occurs whenever anyone fills out one of the contact sales forms and the Reason for Contact is a Sales Inquiry because in my company’s case we did not want to mark support or legal requests as conversions.
  • A Signup Conversion occurs whenever a person’s online portal id i.e. mc user id, gets populated (for people who already exist in Marketo) or someone is created from the Web Service API with their mc user id already populated
Marketo smart list tracking Contact Sales conversions from the ad campaign
Tracking contact sales conversions from the ad campaign
Marketo smart list tracking sign-up conversions from the ad campaign
Tracking sign-up conversions from the ad campaign

Then we will set this person’s status in the Marketo UTM tracking program to either Converted or Contacted depending on which of the above smart campaigns they passed through.

Changing program status to reflect contact sales conversion in Marketo smart campaign flow
Changing program status to reflect contact sales conversion
Changing program status to reflect sign-up conversion in Marketo smart campaign flow
Changing program status to reflect sign-up conversion

Automating UTM Creation & Tracking

Now that you understand how the Marketo UTM tracking program and campaigns are set up, I will show you how you can automate the creation of these programs and campaigns using the Marketo REST API and Zapier.

To do this we will use:

  • A Google Form that will send UTM requests from marketing team members to a Google Sheet triggering a Zap in Zapier to run
  • This Zap will then take the inputs to the Google Form and create the desired UTM parameters using formulas within another UTM Builder Google Sheet
  • The Zap will then create a Marketo UTM tracking program and smart campaigns specific to the newly created UTM parameters
  • Finally, a Jira ticket will be created for Marketing Operations to check that the Marketo UTM tracking program and campaigns were created correctly and then activate the smart campaigns

All the Python code used within the “Code by Zapier” actions can be be found in the “marketo_utm_tracking_automation” directory in Github.

N.B. If it is your first time using the Marketo API or you need a quick refresher then check out the Marketo API Quick-Start Guide to see how to make your first Marketo API requests in Postman before transitioning to making requests in code or in the Zapier automation tool.

If you are really serious about automating the creation of your UTM tracking programs in Marketo then check out lesson 3 in the Marketo API Crash Course where I will walk through how to make all the API requests from the Zapier workflow shown below in Postman. This way you will get a thorough understanding of what each request is doing so that you can build your own UTM tracking program automation workflow.

Collecting UTM Requests from Google Forms

The first step in the whole process is to create a Google Form that will allow a marketing team member to fill out their ad campaign details so that we can automatically create the necessary UTM parameters later on in the UTM Builder sheet. The important thing here is to not require any text entry and only allow the marketer to select from existing options so that you will always know the options available in your form and can thus configure your UTM Builder Google Sheet to create the corresponding UTM parameters for these inputs.

Google form for collecting UTM requests from the marketing team
UTM Request Google Form

Every new submission to the UTM Request Form gets logged in the UTM Request Form Responses sheet, which in turn triggers the Marketo UTM Tracking Automation Zap to run in Zapier.

Google sheet storing submissions from the UTM request form
UTM Request Form Responses

Creating UTM Querystring using Google Sheets Formulas

Zapier actions to create a UTM querystring from the UTM request form submission
Zapier actions to create a UTM querystring from the UTM request form submission

Once the Zap has been triggered, the next step is to take the row ID of this latest submission and use that to search for the row currently filled with “Next Row #” in the UTM Builder sheet.

Looking up the next row in the "UTM Builder" sheet
Looking up the next row in the “UTM Builder” sheet

Originally, this zap was set up so that this step searched for the next empty row in the “UTM Builder” sheet, however, when multiple form submissions were made in quick succession it would turn out that the same row in the “UTM Builder” sheet was being written to/overwritten for each of the submissions.

To get around this race condition, the Campaign Name column in the “UTM Builder” sheet is populated with Next Row # where the row numbers being used correspond to the next available empty rows in the “UTM Form Responses” Google Sheet. This way each successive UTM form submission will be in a a different row in the “UTM Form Responses” sheet and thus will lookup a different row in the “UTM Builder” sheet.

"UTM Builder" Google Sheet
“UTM Builder” Google Sheet

Once the correct row in the “UTM Builder” sheet is found, the Channel and Sub-Channel values are populated from the form submission, at which point the formulas in the Google Sheet take over to create the UTM parameters and querystring automatically.

Putting ad campaign information into the "UTM Builder" sheet
Putting ad campaign information into the “UTM Builder” sheet
Putting ad destination into the "UTM Builder" sheet
Putting ad destination into the “UTM Builder” sheet

Creating a Marketo UTM Tracking Program

Now that the UTM querystring for the ad campaign has been created we want to create the Marketo UTM tracking program and campaigns.

Creating the Marketo UTM tracking program
Creating the Marketo UTM tracking program

The next 5 “Code by Zapier” steps use Python code to make requests to the Marketo REST API to:

  • Get the Marketo access token that is needed to make subsequent requests to the Marketo API (get_marketo_token.py)
  • Get the yearly paid campaigns folder for the current year or create it if it does not already exist (get_year_folder.py)
  • Get the monthly paid campaigns folder for the current month or create it if it does not already exist (get_month_folder.py)
  • Get the most recently created previous Marketo program for the sub-channel of the ad campaign we want to track or if a previous Marketo program cannot be found then default to using a template program (get_latest_program.py)
  • Clone the previous Marketo program for this sub-channel, creating it within the current monthly paid campaigns folder (clone_program.py)
Marketo UTM tracking folder hierarchy
Marketo UTM tracking folder hierarchy

Preparing Marketo UTM Tracking Smart Campaigns

If Step 8 to clone the latest Marketo UTM tracking program for a particular sub-channel is successful then the program ID of the newly created program will be returned. However, I often found that although Marketo was able to successfully create the new program it did not return the successful response and program ID to Zapier within the 10-sec timeout limit imposed on every Zapier action. Therefore, Step 8 would fail along with all the subsequent steps in the zap, which depend on the returned program ID.

In order to remove the dependency on Step 8, Step 9 (get_new_program.py) was added for redundancy and gets the program ID of the newly created program by looking up the name of the program we know was created in Step 8. Now all subsequent steps will use the program ID returned from Step 9 so if Step 8 is ever marked as failed the rest of the zap can continue.

Updating the Marketo UTM tracking program and smart campaigns
Updating the Marketo UTM tracking program and smart campaigns

The next 3 “Code by Zapier” actions:

  • Take the channel, sub-channel, and utm parameters for the ad campaign from Step 3 and use these to populate the utm, lead_source, lead_source_detail,source, medium, and campaign local program tokens (update_program_tokens.py).
  • Get the ids of the 4 smart campaigns nested under the Marketo UTM tracking program (get_smart_campaigns.py).
  • Update the description of these smart campaigns to be the UTM parameters querystring so that it is easy for us as the marketing operations person to copy this value and use it within the smart campaign (see the “Manual Input Required from Marketing Operations” section below)(update_smart_campaigns.py).
Example of the Marketo UTM tracking campaign description containing the UTM querytring for the ad campaign
Example of campaign description containing UTM querytring

Notifying the Marketing Operations Team

Once the Marketo UTM tracking program and campaigns are ready, we then need to create a ticket for the marketing operations team so that they can review the program and campaigns and do the small bit of manual work outlined below.

Creating a Jira ticket for the marketing operations team
Creating a ticket for marketing operations
  • The email address associated with the “UTM Request Form” submission is used to lookup the Jira ID for this person
  • This Jira ID is then used in the “Reporter” field when creating the Jira ticket (see image below)
  • The Jira ticket is then moved from the backlog into the “To Do” column of the marketing operations person assigned to the ticket
Populating the Marketo UTM Tracking Program ticket from previous Zapier actions
Populating the Marketo UTM Tracking Program ticket

A Slack message, email, or SMS notification containing the same information as in the Jira ticket could also be added here.

Manual Input Required from Marketing Operations

Since the Jira ticket contains a link to the Marketo UTM tracking program that was created by the Zap, it is very easy for marketing operations to open up this ticket and go straight to the Marketo program.

While tokens can be used in “Change Data Value” flow steps they cannot be used in the “Querystring” constraint of the “Visits Web Page” trigger in the “01 Visit” smart list or in the “Lastest Touch” filters in the “02 Contacted” or “02 Converted” smart lists.

This is why manual input is required to update the smart lists with the UTM querystring for the ad campaign. Thankfully, our “Marketo UTM Tracking Automation” zap updated the description of these smart campaigns to be the UTM querystring so we can copy the querystring right from the description before pasting into the smart lists.

Once all the smart campaigns have been activated or scheduled the last piece of manual work required is just to set up the “Salesforce Campaign Sync” so that the leads generated from this Marketo program can be sent to a corresponding Salesforce campaign.

Marketo UTM Tracking Related Content

Now that you have mastered Marketo UTM tracking and you have streamlined the hand-off from your marketing team to the marketing operations team you can move on to tracking organic visits to your site and reporting on the effectiveness of each of your marketing channels.

  • The Marketo Program Cloning Via API post will show you how to clone all your attribution programs on either monthly, quarterly, or yearly frequencies so you can get the resolution you need for Salesforce campaign influence reporting and your multi-touch attribution modelling.
  • Marketo Anonymous Leads & Attribution: Understand the nuances of anonymous leads in Marketo and what you need to be aware of when building the organic attribution campaigns that these leads can qualify for.
  • If you want to get started on adding period costs to your paid ad programs in Marketo so that you can report on “Cost Per Acquisition” then take a look at the Zapier Nested Looping using Webhooks & Python, which shows you how to automate this process.

If you are really serious about automating the creation of your UTM tracking programs in Marketo then check out lesson 3 in the Marketo API Crash Course where I will walk through how to make all the API requests from this blog post in Postman. This way you will get a thorough understanding of what each request is doing so that you can build your own UTM tracking program automation workflow.

As always if you are enjoying this content and want to receive emails when I launch new posts then click the big, pink, shiny subscribe button at the top of the page ðŸ™‚

Leave a Reply

Your email address will not be published. Required fields are marked *