在网站中嵌入调查
虽然我们可以使用很多方式来发送调查,但嵌入选项可以直接在网页上显示 Dynamics 365 Customer Voice 窗体。 您可以从特定调查上的发送选项卡访问嵌入选项。 请务必知悉,需要为当前查看的调查提供唯一的嵌入代码。
调查的嵌入页面为您提供三个不同的可用格式。
嵌入样式 | 详细信息 |
---|---|
内联 | 调查会直接嵌入到网页并以静态形式显示,其样式与使用 iFrame 时非常类似。 您可以使用内联代码将调查置于页面上的任何位置。 |
弹出窗口 | 弹出窗口可用于在页面中间显示调查,使其覆盖下方的网页。 |
按钮 | 使用按钮代码时,相应按钮就会显示在网页的右下角,选中按钮即可为网站访问者展开显示调查。 |
选择嵌入格式后,看到代码时,选择复制按钮即可将其添加到用户的剪贴板,然后您可以将代码粘贴到记事本(或任何代码编辑器)中查看。
代码与以下示例大体类似:
<script src="https://mfpembedcdntip.azureedge.net/mfpembedconttip/Embed.js" type="text/javascript"></script><link rel="stylesheet" type="text/css" href="https://mfpembedcdntip.azureedge.net/mfpembedconttip/Embed.css" /><script type = "text/javascript" >function renderSurvey(parentElementId,FirstName, LastName, ProductPage){var se = new SurveyEmbed("UMck_jU0zkqaWu5hQY9ZJfSe99ccZGtMuDUB_NkyHxRUQjJNU1dMNEc1ODVWOFdTRTMwNlowQTVPMS4u","https://forms.office.com/","https://mfpembedcdntip.azureedge.net/mfpembedconttip/","true");var context = {"First Name": FirstName,"Last Name": LastName,"ProductPage": ProductPage,};se.renderInline(parentElementId, context);}</script>
添加到调查中的任何变量都将显示在代码末尾。 上述脚本显示了 First Name、Last Name 和 ProductPage 变量。 无法从调查中删除 First Name 和 Last Name 变量,因此,您必须将其保留在代码中。 随后,网站管理员可以将代码添加到网页。 仅添加本代码无法显示调查。 需要添加更多元素才能使其可见。 必须使用名为内容部门 (DIV) 标记的元素来显示调查,该标记用于规定调查在网站页面上的显示位置。 调查的高度和宽度则可以使用一些样式元素进行设置。
<div id="surveyDiv" style="height: 700px; width:600px; margin-left:auto; margin-right:auto"></div>
从 Dynamics 365 Customer Voice 调查复制代码后,请立即添加 DIV 元素,确保调查可以显示在网站中。 不过,您也可以通过在调查中使用变量来传递相关值。 设想一下,现有一个用于捕获潜在客户的调查,站点访问者可以在不同的产品网页上完成该调查。 在这种情况下,您每次都可以使用相同的调查,只需从网页上传递产品名称这一变量即可。 要完成本任务,您需要在 DIV 元素之间添加以下脚本。
如前所述,First Name 和 Last Name 变量无法删除,但是,您可以传递 Lead 和 Capture 两个变量,分别用作 First Name 和 Last Name。 ProductPage 变量可用于传递产品名称,而上述所有三个信息均将伴随每次调查回复传回 Dynamics 365 Customer Voice。
<script>
window.addEventListener('load', function () {
renderSurvey("surveyDiv","Lead","Capture","Product A");
}, false);
</script>
整个代码与以下示例大体类似。
<script src="https://mfpembedcdntip.azureedge.net/mfpembedconttip/Embed.js" type="text/javascript"></script><link rel="stylesheet" type="text/css" href="https://mfpembedcdntip.azureedge.net/mfpembedconttip/Embed.css" /><script type = "text/javascript" >function renderSurvey(parentElementId,FirstName, LastName, ProductPage){var se = new SurveyEmbed("UMck_jU0zkqaWu5hQY9ZJfSe99ccZGtMuDUB_NkyHxRUQjJNU1dMNEc1ODVWOFdTRTMwNlowQTVPMS4u","https://forms.office.com/","https://mfpembedcdntip.azureedge.net/mfpembedconttip/","true");var context = {"First Name": FirstName,"Last Name": LastName,"ProductPage": ProductPage,};se.renderInline(parentElementId, context);}</script>
<center>
<div id="surveyDiv" style="height: 700px; width:600px; margin-left:auto; margin-right:auto">
<script>
window.addEventListener('load', function () {
renderSurvey("surveyDiv","Lead","Capture","Product A");
}, false);
</script>
</div>
</center>