Skip to main content

Notifications

Announcements

No record found.

Customer Insights - Journeys forum

segments and form handler

Posted on by Microsoft Employee

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

  • Verified answer
    ShravanSuri Profile Picture
    ShravanSuri 1,255 on at
    RE: segments and form handler

    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>

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

November Spotlight Star - Khushbu Rajvi

Congratulations to a top community star!

Forum Structure Changes Coming on 11/8!

In our never-ending quest to help the Dynamics 365 Community members get answers faster …

Dynamics 365 Community Platform update – Oct 28

Welcome to the next edition of the Community Platform Update. This is a status …

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 291,269 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 230,198 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans