Skip to main content

Surveys - Sharing responses with 3rd party systems

O
Written by Optimize Team
Updated this week

This article describes how to relay responses from Webtrends Optimize surveys into 3rd party platforms.

Data flow

Webtrends Optimize broadcasts "message" events from our survey frames which you are able to latch onto.

Messages come from the PostMessaging API, and often are used by other platforms too.

Our messages contain specific parameters that clearly highlight that they are coming from our system, and so with a small amount of filtering you're able to latch onto the correct events fairly easily, per the example below.

These connectors can be placed inside a global script like preinit, in which case they will trigger for all surveys in the platform and not be a per-test effort.

Example - Generic connector

window.addEventListener("message", function(e){

let isWTOSurvey = e.data?.service === "wto" && e.data?.product === "surveys";
let isSubmissionEvent = e.data?.status === "submission";

if(isWTOSurvey && isSubmissionEvent){
let surveyData = e.data.data;
if(!surveyData){
// something went wrong;
return;
}

// do something
}

});

Example - Google Tag Manager (GTM)

Code:

window.addEventListener("message", function(e){

let isWTOSurvey = e.data?.service === "wto" && e.data?.product === "surveys";
let isSubmissionEvent = e.data?.status === "submission";

if(isWTOSurvey && isSubmissionEvent){
let surveyData = e.data.data;
if(!surveyData){
// something went wrong;
return;
}

window.dataLayer = window.dataLayer || [];
dataLayer.push({
event: "wto_survey_submission",
...surveyData
});
}

});

Observable outcome:

Notes:

  • In this example, we've used the "spread" operator to avoid unnecessary nesting of data.

Did this answer your question?