Capturing UTM parameters in the submitted RTM form - how to do it in Customer Insights Journey?
You read:
Capturing UTM parameters in the submitted RTM form – how to do it in Customer Insights Journey?
Capturing UTM parameters in the submitted RTM form - how to do it in Customer Insights Journey?
In marketing, knowing the source of our leads seems like a basic requirement—it’s simply something you need to know. This is especially true if we are conducting paid promotional activities aimed at acquiring leads. Typically, target addresses in such campaigns are tagged with UTM parameters. This also applies to links shared on social media. The purpose is to accurately assess the effectiveness of our current activities and choose the best media and channels for future campaigns.
In Google Analytics, we can see the quantity of traffic from each campaign, but Customer Insights – Journey allows for capturing these parameters from the URL to our form and saving them directly in the lead record. This means that every lead created from a campaign where tags were used has its source (website, social media, mailing system, etc.), medium (CPC, newsletter, banner, etc.), campaign (the specific campaign name, e.g., winter_sale), or content the user clicked to view the form (e.g., image, footer, link, etc.).
Recipe for Capturing UTM Parameters and Saving Them in a Lead Record
Ingredients:
- 4 columns in the Lead table
- 1 lead capture form (self-published or embedded on a website)
- 4 hidden fields in the form
- 1 script to automatically populate the form fields with UTM parameter data
Steps:
- In the Lead table, add the necessary columns to save the UTM parameters captured from the form URL. You will need the following columns:
- Refferer URL
- UTM Campaign
- UTM Content
- UTM Medium
- UTM Source
Create the necessary form extended with the new fields you just added. Place them at the very end.
NOTE! The fields should be hidden.
3. Open the HTML form editor. Find the closing tag, and insert the script after it.
4.In the HTML editor, add a script that will capture UTM parameters from the URL upon form loading and place them in the added fields on the form. The script should be placed after thetag and before the tag. The sample script below will save parameter values if they exist. It does not check if the parameter has a value or not. In such a case, the field in the record will also remain empty.
How does our script work exactly?
- It fills the form fields with data from UTM parameters
- The script listens for the d365mkt-afterformload event, triggered after the form is loaded.
- The populateFormFields function uses URLSearchParams to retrieve parameters from the current URL.
- Then, it locates the appropriate form fields based on labels and fills them with data such as source (utm_source), campaign (utm_campaign), medium (utm_medium), and content (utm_content).
- Additionally, it populates the “Referrer URL” field with the value from document.referrer (the URL from which the user came to the current page).
- It handles post-submit events:
- The script also listens for the d365mkt-afterformsubmit event, triggered after the form is submitted.
- In the case of success (event.detail.successful), it logs information about the success and displays the data passed in the payload (event.detail.payload), which includes data related to the submitted form.
Summary
This simple recipe allows us to gather additional information that enables us to check the effectiveness of our form-based campaigns and clearly identify the source of each lead. Of course, if we forget to tag the URLs used in the campaigns, our method will not work because the fields will remain empty (except for the Referrer URL field, which will indicate the referring page), and this will be recorded in the Lead’s record.