Hi there
Is there a way that you can build a form on a landing page with a form handler, so that it tracks the activity coming from the different marketing channels and then in turn add the contact to a specific segment?
For example, if I have one landing page but activity is coming from LinkedIn and Facebook, so all the traffic is going to one form but I want to track where the submission comes from and add them to a specific segment. Can this be done with a form handler or something similar?
Or do I have to create a different landing page for each channel in order to track?
Thanks
Georgie
Hey Georgie, excellent use case. The easiest way to do this tracking is to:
1. Add a hidden field on your form, and map it to your contact/lead
2. On the form submission, use Javascript to pass the value of the channel (which you can pick from the URL, which is where I'm assuming you're keeping the channel field) as a part of the form submission by setting the value of the hidden field as this channel.
Here's a sample script for your landing page with the form, which takes all the parameters in the URL and adds them to the hidden fields array. You can of course simplify it if you're just using a single field.
<script>
MsCrmMkt.MsCrmFormLoader.afterformload = function(formPageId)
{
var self = window.location.toString();
var queryString = self.split("?");
var hiddenFields = document.querySelectorAll("input[type=hidden]");
if (queryString.length > 1)
{
var pairs = queryString[1].split("&");
for (var pairIndex in pairs)
{
var pair = pairs[pairIndex].split("=");
if (pair.length !== 2)
{
continue;
}
var key = pair[0];
var value = pair[1];
if (key && value)
{
for (var i = 0; i < hiddenFields.length; i++)
{
if (hiddenFields[i].id === key)
{
hiddenFields[i].value = value;
}
}
}
}
}
}
</script>
André Arnaud de Cal...
292,160
Super User 2025 Season 1
Martin Dráb
230,962
Most Valuable Professional
nmaenpaa
101,156