In a previous blog post, I walked through how to capture the referral url via a marketing form submission and pass it back through as an unmapped form field. This got me thinking about other pieces of information that could be valuable. As a marketer, hopefully you are using and understand UTM Parameters, which can be passed through a URL and then used to analyse your website visits and success of campaigns in Google Analytics. Although currently there isn’t any functionality directly within D365 Marketing for adding UTM Parameters, ideally you are still adding them to the links in your marketing emails. In this post we will look at how you can capture those, and pass them back through in your form submissions and also map through to a Lead record if required.
There are several tools that exist to build urls for your campaigns, but my preferred one is the free tool from Google that you can find here: Campaign URL Builder. It’s really easy to use. First, you add the url that you want to take someone to when they click on the link from an email, paid online ad, or social media post. There are several options available, and you can use any that make sense for your organisation, but only campaign source and campaign medium are required. In this example, I’m creating a link I would share on Twitter (campaign source) and sharing as an organic social post (campaign medium). I am also naming my campaign marketing form submissions (campaign name) and it’s a general post (campaign content). These are open to interpretation but there are best practices Google suggests you follow.
Once you’ve added the various fields, your campaign url will be generated which can then be shared (either as the full or a shortened link).
When someone clicks on a link and that link includes a D365 Marketing form, how can we find out what the UTM parameters were? First thing, decide if you want to capture that information on new leads. If you do, add your new single line text fields on the Lead table. Then add in your new marketing form fields. Here we can see that I’ve gone with 4 different UTM parameters, and also the referrer URL (that I referenced in this post here). I’ve then mapped them to the new Lead field, but left the Contact mapping empty. You can map to Contact fields if you wish, but not a good idea to have this overwritten each time so I am leaving those unmapped. Make a note of the GUID (the id at the end of the URL) for each of your new marketing form fields, you will need those later.
Now we add those to a marketing form and make all of these fields hidden.
If you want to make sure a Lead gets created every time the form is filled out, make sure you change the Generate leads without matching field to Yes.
Make the form live, and get the generated JavaScript from the form hosting area on your form. You will then need to add that script to your web page, and then also add the script below. Where it shows YOUR_FIELD_ID, replace that with each of the GUIDS for each of your new form fields you created. Check out this post for a handy way to generate this new code on your form page records so it’s automatically provided for you on each form. MASSIVE thank you to my brother @Owen Rumney for helping me with the script.
<script> MsCrmMkt.MsCrmFormLoader.on("afterFormLoad", function() { let query = new URLSearchParams(document.location.search); document.getElementById("YOUR_FIELD_ID").value = document.referrer; document.getElementById("YOUR_FIELD_ID").value = query.get("utm_source"); document.getElementById("YOUR_FIELD_ID").value = query.get("utm_medium"); document.getElementById("YOUR_FIELD_ID6").value = query.get("utm_campaign"); document.getElementById("YOUR_FIELD_ID").value = query.get("utm_content"); }); </script></div>
Once you’ve added your marketing form to your website, and you’ve got the link you generated using the Campaign URL Builder tool from Google, you can start sharing your link (or lots of links!). Hopefully hundreds of people flock to fill it out and you start getting submissions. Here we can see the form field submissions are getting populated with the data. We can see the referrer URL populated with the link for Twitter, then all of the UTM Parameters populated with the correct information from the URL.
If you are generating internal email notifications for form submissions, that should also include the UTM Parameters.
And if you’ve mapped the fields to a Lead record, they should also be populated with the information you need.
*This post is locked for comments