Using Parameters To Pass Forms Pro Survey Context

*** NOTE: ALL INFORMATION IS ACCURATE AT DATE OF PUBLISHING ***

| CLICK IMAGES IN THE POST TO ENLARGE THEM |

So far we’ve covered a lot on Microsoft Forms Pro. This post comes with some feedback and knowledge direct from a member of the Forms Pro team at Microsoft. So special thanks to Prateek Sethi for providing guidance with the steps for the Microsoft Flow, and using the parameters effectively. In this post we will look at a simple scenario where we can create one survey, but use it on multiple web pages. Then pass a parameter back through from the web page to let us know which page they were on when they completed the survey. This allows us to do something effective like create a new Lead record when a visitor expresses interest in a specific product and capture which product they are interested in. We start off with a simple survey.

Next, we want to make sure anyone with the link (or visiting the web page where it’s embedded) can complete the survey. Click on the gear icon from the top right of the survey to go to the form settings and make sure the first radio button is selected so anyone with the link can respond.

Now we need to click on the Send Survey tab, and then click the Embed option. We will keep it inline to embed the survey on a page on our website.

Before we get the embed code, we need to add in a new parameter to pass context back in to the survey and let us know which product page the survey was on. Add in a new parameter called ProductPage (or whatever parameter you wish to pass back).

Now scroll to the bottom and click on Generate code.

For more information on how to embed your survey, take a look at this blog post which covers it in more detail. The important part that needs to be reviewed to pass the parameter back is in the render survey method. Right after “surveyDiv” we need to add in the product name for this specific web page. So if it’s being added to the sales page about Product A, we add that in quotes right after the surveyDiv parameter.

<div id="surveyDiv" style="height: 800px">
<script>
	 window.addEventListener('load', function () {
            renderSurvey("surveyDiv","Product A");
        }, false);
</script>
</div>

Now we have that on the web page, we need a Microsoft Flow that will run when someone submits the survey from the website. The Microsoft Forms Pro data is created in Common Data Service. We will give the Flow a name and select the Common Data Service trigger, When a record is created. Click the Create button to move on to the next step.

Select your environment, then Survey responses in the Entity name, and the scope as Organisation.

Our first action is from the Microsoft Forms connector. There is only one, and that’s to ‘Get response details’.

We need to get the response id of the new survey response record. To do this, we need to convert the response id to an integer value. For this, we click in the Response id field in the action, then click on the Expression tab on the right, and paste in the following, then click OK.

int(triggerBody()?['msfp_sourceresponseidentifier'])

Now we need to get the parameter we added to the survey embed code that tells which page, or product the responder was on when they submitted the survey. To do this, we are going to use the Parse JSON action. In the Content field, select the Context Data from the initial trigger step of your flow.

Click on the link at the bottom of the Schema field – ‘use sample payload to generate schema’.

Past the following in to the window that opens, making sure you use the exact name of the parameter you added to the survey in Forms Pro. Where it says “Product Name” this can say anything. It will be replaced by the ACTUAL product name you added to the website.

{"EmbedContextParameters":{"ProductPage":"Product Name"}}

Once you have clicked Done, you will see the Schema formatted correctly. Each time the flow runs, it will parse the context data and the ProductPage value.

Now let’s create a new Lead record in Dynamics 365 Customer Engagement using the Common Data Service action to create a new record. We select the right environment, and set the leads entity. We are then able to use the values from the Microsoft Forms step and get the values populated by the responder in the survey on the website. How cool is that! We will use the Last Name, First Name and Email fields to add in the corresponding survey fields. For the Topic, you can add whatever makes sense for your organisation, but here we have “Product Interest – “ followed by the value from the Parse JSON step which contains the ProductPage parameter.

Once we have created the Lead, it makes sense to now link the Lead back to the original Survey Response record. So, let’s add another Common Data Service action step, and select the Survey resopnses entity again. The record identifier is the Activity id from the original Survey response trigger at the start of the Flow. It might also be a good idea to update the Subject of the survey response and include the ProductPage value from the Parse JSON step.

Scroll down and update the Regarding field using the Lead from the Create Lead step, and set the Regarding Type as leads.

We can use the name fields from the survey response to update the Respondent field, and the email to update the respondent email address just to round it out nicely.

Looking in Dynamics 365 for Customer Engagement we see the Lead record has been created with the Topic including the Product from the ProductPage parameter.

If we drill down in to the Survey response record we see that it also identifies the product, and it’s got the Lead set as the regarding record.

We can now use this survey in all product pages on a website, but by passing through the ProductPage parameter from the survey, and using it in our Flow, we will get a clear and immediate understanding of where our new Leads are coming from.

Want to just watch how to do this? Check out the video below:

6 thoughts on “Using Parameters To Pass Forms Pro Survey Context

  1. The trigger will fire for any survey. What expression would you add as a trigger condition to ensure that it only fires for the expected survey ?

    1. Hi Bertrand, thanks for the comment. Yes, add a Condition action after the trigger, and add msfp_sourcesurveyidentifier eq ‘YOUR SURVEY ID’. If yes, then you carry on with your FLOW. You can get the source survey identifier from CDS but doing an advanced find for surveys, and add that field to your view, then export and you can copy the id. I hope that helps!

Leave a Reply

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