We fire several events on the document element of the website our form is active. We do this so you can easily hook into our form events to work with data related to our forms.
We have the following events available:
mopinion_loaded
mopinion_shown
mopinion_hidden
mopinion_next (standard forms only)
mopinion_previous (standard forms only)
mopinion_feedback_sent
mopinion_redirect
mopinion_question_answered (conversational forms only)
You can use an event listener to hear when a Mopinion event has taken place. You can then use the occurrence of an event to trigger your own script. With your own script you can, for example, log your feedback in the browser console or push the feedback to your own analytics program.
The structure of the event listener is as follows:
document.addEventListener('[MOPINION_EVENT_NAME]', function(e) { [YOUR_OWN_TO_BE_EXECUTED_SCRIPT] }); |
Replace [MOPINION_EVENT_NAME] with one of the eight Mopinion Events.
Replace [YOUR_OWN_TO_BE_EXECUTED_SCRIPT] with your own script.
In the remaining part of this article, we provide scripts for all 8 events to log the event variables and values in the browser console, push the event variables and values in the Google Tag Manager dataLayer and how that will look in the console/dataLayer.
The events fired are as follows:
With this event, you know when a form is loaded, but not yet shown, on a page.
You can use the following JavaScript to display the event's output in the browser's console:
document.addEventListener('mopinion_loaded', function(e) { console.log(e.detail); }); |
Specific code to push the Event Object into the Google Tag Manager dataLayer:
<script type="text/javascript"> document.addEventListener('mopinion_loaded', function(e) { window.dataLayer.push(e.detail); }); </script> |
The result in the console / dataLayer:
{ event: "loaded", key: "[UNIQUE_FORM_KEY]", formName: "[FORM_NAME]" } |
With this event, you know when the feedback form is shown.
You can use the following JavaScript to display the event's output in the browser's console:
document.addEventListener('mopinion_shown', function(e) { console.log(e.detail); }); |
Specific code to push the Event Object into the Google Tag Manager dataLayer:
<script type="text/javascript"> document.addEventListener('mopinion_shown', function(e) { window.dataLayer.push(e.detail); }); </script> |
The result in the console / dataLayer:
{ event: "shown", key: "[UNIQUE_FORM_KEY]", formName: "[FORM_NAME]", triggerMethod: "[PASSIVE | PROACTIVE | EXIT]" } |
With this event, you know when the feedback form is hidden again.
You can use the following JavaScript to display the event's output in the browser's console:
document.addEventListener('mopinion_hidden', function(e) { console.log(e.detail); }); |
Specific code to push the Event Object into the Google Tag Manager dataLayer:
<script type="text/javascript"> document.addEventListener('mopinion_hidden', function(e) { window.dataLayer.push(e.detail); }); </script> |
The result in the console / dataLayer:
{ event: "hidden", key: "[UNIQUE_FORM_KEY]", formName: "[FORM_NAME]", triggerMethod: "[PASSIVE | PROACTIVE | EXIT]" } |
If your standard feedback form consists of multiple pages this event, will let you know when navigation to the next page takes place. It also makes all the feedback given until that point available. The array with all possible questions is updated with the value of the answered question till then.
You can use the following JavaScript to display the event's output in the browser's console:
document.addEventListener('mopinion_next', function(e) { console.log(e.detail); }); |
Specific code to push the Event Object into the Google Tag Manager dataLayer:
<script type="text/javascript"> document.addEventListener('mopinion_next', function(e) { window.dataLayer.push(e.detail); }); </script> |
The result in the console / dataLayer:
{ event: "next", key: "[UNIQUE_FORM_KEY]", formName: "[FORM_NAME]", triggerMethod: "[PASSIVE | PROACTIVE | EXIT]", feedback: [ { id: "[UNIQUE_SURVEY_BLOCK_ID]", label: "[IMPORT_VAR]", title: "[QUESTION]", type: "[DATAFIELD_TYPE]", value: "[VALUE]" }, { id: "[UNIQUE_SURVEY_BLOCK_ID]", label: "[IMPORT_VAR]", title: "[QUESTION]", type: "[DATAFIELD_TYPE]", value: "[VALUE]" }, ...(rest_of_survey_fields), { label: "User Agent", type: "agent", value: [BROWSER_USER_AGENT] }, { label: "url" type: "url" value: [URL_WHERE_THE_FORM_IS_SHOWN] }, { label: "Page title" type: "category" value: [PAGE_TITLE_WHERE_THE_FORM_IS_SHOWN] }, { label: "Role" type: "role" value: 1 }, { label: "Survey" type: "category" value: [FORMNAME] }, { label: "Viewport" type: "viewport" value: [LENGTH x WIDTH] }, { label: "Form trigger" type: "category" value: [PASSIVE | PROACTIVE | EXIT] }, { label: "Form completion percentage" type: "form_completion" value: [PERCENTAGE_OF_PAGES_COMPLETED] }, { label: "Customer ID" type: "customer" value: [UNIQUE_ID_GENERATED_ON_] }, { label: "Survey ID" type: "id" value: [UNIQUE_SURVEY_RESULT_ID] } ] } |
If your standard feedback form consists of multiple pages this event, will let you know when navigation to the previous page takes place. It also makes all the feedback given until that point available. The array with all possible questions is updated with the value of the answered question till then.
You can use the following JavaScript to display the event's output in the browser's console:
document.addEventListener('mopinion_previous', function(e) { console.log(e.detail); }); |
Specific code to push the Event Object into the Google Tag Manager dataLayer:
<script type="text/javascript"> document.addEventListener('mopinion_previous', function(e) { dataLayer.push(e.detail); }); </script> |
The result in the console / dataLayer:
{ event: "previous", key: "[UNIQUE_FORM_KEY]", formName: "[FORM_NAME]", triggerMethod: "[PASSIVE | PROACTIVE | EXIT]", feedback: [ { id: "[UNIQUE_SURVEY_BLOCK_ID]", label: "[IMPORT_VAR]", title: "[QUESTION]", type: "[DATAFIELD_TYPE]", value: "[VALUE]" }, { id: "[UNIQUE_SURVEY_BLOCK_ID]", label: "[IMPORT_VAR]", title: "[QUESTION]", type: "[DATAFIELD_TYPE]", value: "[VALUE]" }, ...(rest_of_survey_fields), { label: "User Agent", type: "agent", value: [BROWSER_USER_AGENT] }, { label: "url" type: "url" value: [URL_WHERE_THE_FORM_IS_SHOWN] }, { label: "Page title" type: "category" value: [PAGE_TITLE_WHERE_THE_FORM_IS_SHOWN] }, { label: "Role" type: "role" value: 1 }, { label: "Survey" type: "category" value: [FORMNAME] }, { label: "Viewport" type: "viewport" value: [LENGTH x WIDTH] }, { label: "Form trigger" type: "category" value: [PASSIVE | PROACTIVE | EXIT] }, { label: "Form completion percentage" type: "form_completion" value: [PERCENTAGE_OF_PAGES_COMPLETED] }, { label: "Customer ID" type: "customer" value: [UNIQUE_ID_GENERATED_ON_] }, { label: "Survey ID" type: "id" value: [UNIQUE_SURVEY_RESULT_ID] } ] } |
With this event, you know when the feedback form is completely submitted.
You can use the following JavaScript to display the event's output in the browser's console:
document.addEventListener('mopinion_feedback_sent', function(e) { console.log(e.detail); }); |
Specific code to push the Event Object into the Google Tag Manager dataLayer:
<script type="text/javascript"> document.addEventListener('mopinion_feedback_sent', function(e) { window.dataLayer.push(e.detail); }); </script> |
The result in the console / dataLayer:
{ event: "feedback_sent", key: "[UNIQUE_FORM_KEY]", formName: "[FORM_NAME]", triggerMethod: "[PASSIVE | PROACTIVE | EXIT]", feedback: [ { blockType: "[QUESTION_TYPE]", field: "[QUESTION_TYPE_&_UNIQUE_SURVEY_BLOCK_ID]", id: "[UNIQUE_SURVEY_BLOCK_ID]", label: "[IMPORT_VAR]", title: "[QUESTION]", type: "[DATAFIELD_TYPE]", value: "[VALUE]" }, { blockType: "[QUESTION_TYPE]", field: "[QUESTION_TYPE_&_UNIQUE_SURVEY_BLOCK_ID]", id: "[UNIQUE_SURVEY_BLOCK_ID]", label: "[IMPORT_VAR]", title: "[QUESTION]", type: "[DATAFIELD_TYPE]", value: "[VALUE]" }, ...(rest_of_survey_fields), { label: "User Agent", type: "agent", value: [BROWSER_USER_AGENT] }, { label: "url" type: "url" value: [URL_WHERE_THE_FORM_IS_SHOWN] }, { label: "Page title" type: "category" value: [PAGE_TITLE_WHERE_THE_FORM_IS_SHOWN] }, { label: "Role" type: "role" value: 1 }, { label: "Survey" type: "category" value: [FORMNAME] }, { label: "Viewport" type: "viewport" value: [LENGTH x WIDTH] }, { label: "Form trigger" type: "category" value: [PASSIVE | PROACTIVE | EXIT] }, { label: "Form completion percentage" type: "form_completion" value: [PERCENTAGE_OF_PAGES_COMPLETED] }, { label: "Customer ID" type: "customer" value: [UNIQUE_ID_GENERATED_ON_] }, { label: "Survey ID" type: "id" value: [UNIQUE_SURVEY_RESULT_ID] } ] } |
With this event, you know when a link within a feedback form is clicked and to what page is being redirected.
You can use the following JavaScript to display the event's output in the browser's console:
document.addEventListener('mopinion_redirect', function(e) { console.log(e.detail); }); |
Specific code to push the Event Object into the Google Tag Manager dataLayer:
<script type="text/javascript"> document.addEventListener('mopinion_redirect', function(e) { window.dataLayer.push(e.detail); }); </script> |
The result in the console / dataLayer:
{ event: "redirect", key: "[UNIQUE_FORM_KEY]", formName: "[FORM_NAME]", url: "[URL_TO_WHICH_IS_BEING_REDIRECTED]" } |
With this event, you know when a question in a conversational form has been answered. The array with all possible questions is updated with the value of the just-answered question. The ending element
tells what the last answered question was up till that point. As a value, the question title is provided.
You can use the following JavaScript to display the event's output in the browser's console:
document.addEventListener('mopinion_question_answered', function(e) { console.log(e.detail); }); |
Specific code to push the Event Object into the Google Tag Manager dataLayer:
<script type="text/javascript"> document.addEventListener('mopinion_question_answered', function(e) { window.dataLayer.push(e.detail); }); </script> |
The result in the console / dataLayer:
{ event: "question_answered", key: "[UNIQUE_FORM_KEY]", formName: "[FORM_NAME]", triggerMethod: "[PASSIVE | PROACTIVE | EXIT]", feedback: [ { blockType: "[QUESTION_TYPE]", field: "[QUESTION_TYPE_&_UNIQUE_SURVEY_BLOCK_ID]", id: "[UNIQUE_SURVEY_BLOCK_ID]", label: "[IMPORT_VAR]", title: "[QUESTION]", type: "[DATAFIELD_TYPE]", value: "[VALUE]" <-- updated by the question }, { blockType: "[QUESTION_TYPE]", field: "[QUESTION_TYPE_&_UNIQUE_SURVEY_BLOCK_ID]", id: "[UNIQUE_SURVEY_BLOCK_ID]", label: "[IMPORT_VAR]", title: "[QUESTION]", type: "[DATAFIELD_TYPE]", value: "[VALUE]" <-- to be updated by the next question }, ...(rest_of_survey_fields), { label: "User Agent", type: "agent", value: [BROWSER_USER_AGENT] }, { label: "url" type: "url" value: [URL_WHERE_THE_FORM_IS_SHOWN] }, { label: "Page title" type: "category" value: [PAGE_TITLE_WHERE_THE_FORM_IS_SHOWN] }, { label: "Role" type: "role" value: 1 }, { label: "Survey" type: "category" value: [FORMNAME] }, { label: "Viewport" type: "viewport" value: [LENGTH x WIDTH] }, { label: "Form trigger" type: "category" value: [PASSIVE | PROACTIVE | EXIT] }, { label: "Form completion percentage" type: "form_completion" value: [PERCENTAGE_OF_PAGES_COMPLETED] }, { label: "Customer ID" type: "customer" value: [UNIQUE_ID_GENERATED_ON_] }, { label: "Survey ID" type: "id" value: [UNIQUE_SURVEY_RESULT_ID] }, { label: "Ending element" type: "[DATAFIELD_TYPE]", value: "[QUESTION]", } ] } |
The labels |
Some content in the output is available in different ways. |