Medallia Event Listener
How to track Medallia Feedback and Form Widget Interactions with google tag manager
This section of this resource page will walk you through the process of using the Medallia event listener script with Google Tag Manager (GTM) to track visitor interactions with the Medallia feedback and form widgets on your website. With this setup, you can send this data to your analytics tools like Google Analytics (GA4), Piwik Pro, Mixpanel, and more to gain valuable insights into user behavior.
Step 1: Adding the Medallia Event Listener Script to GTM
Start by copying the provided Medallia event listener script and creating a new tag in Google Tag Manager of the Custom HTML tag type. Paste the script into the tag, assign it a name (e.g., “Medallia Event Listener”), and configure it to trigger on DOM Ready.
💡 Pro Tip: Firing the tag on DOM Ready ensures that the Medallia widgets are fully loaded before the event listener script is activated.
The event listener script tracks various interactions with the Medallia feedback and form widgets, such as invites displayed, feedback submitted, and forms closed. For every tracked interaction, the script pushes a dataLayer
event named medallia_gtm_events
along with additional details like the action type, form ID, and feedback UUID.
The key variable medallia_action
captures the type of interaction. Here’s a list of tracked actions:
- Invite displayed
- Invite accepted
- Invite declined
- Invite skipped
- Form call triggered
- Feedback button displayed
- Form displayed
- Form page displayed
- Form next page
- Form back page
- Form closed after submission
- Form closed without submission
- Feedback submitted
- Feedback button clicked
- Thank you displayed
- Thank you closed
- Screen capture started
- Screen capture taken
- Screen capture canceled
Step 2: Creating a Custom Event Trigger in GTM
Next, set up a custom event trigger in Google Tag Manager.
- Navigate to Triggers in GTM and create a new trigger.
- Select the trigger type Custom Event.
- Enter
medallia_gtm_events
as the event name. - Save the trigger and assign it an appropriate name (e.g., “CE – Medallia Event Trigger”).
This trigger ensures that your tags fire whenever a Medallia interaction event is recorded.
Step 3: Creating DataLayer Variables
To capture detailed information about the Medallia interactions, you’ll need to create the following DataLayer variables in GTM:
medallia_action
: Returns the type of Medallia interaction/event (e.g., invite accepted, feedback submitted).medallia_form_id
: Provides the ID of the feedback or form.medallia_form_type
: Indicates the type of form used.medallia_feedback_uuid
: Contains the unique identifier for the feedback.medallia_content
: Includes the content of the feedback, if applicable.
To create these variables:
- Go to Variables in GTM and create a new variable of type Data Layer Variable.
- Assign the appropriate key to each variable (e.g.,
medallia_action
for the action type). - Save the variables with descriptive names (e.g., “DLV – Medallia Action”).
Step 4: Creating Marketing Tags and Utilizing Variables
After setting up your trigger and variables, the next step is to create your marketing tags, such as GA4 or Piwik Pro event tags.
- Create a new tag in GTM (e.g., GA4 Event Tag).
- Use the custom event trigger (
medallia_gtm_events
) created earlier to fire the tag. - Leverage the DataLayer variables (e.g.,
medallia_action
,medallia_form_id
) in your tag configuration to add context to the event data.
This ensures that the data sent to your analytics platforms includes detailed insights about Medallia widget interactions, allowing for more effective analysis.
Additional Implementation Notes:
The Medallia event listener script is tag manager agnostic, meaning it can be used with other Tag Management Solutions (TMS) beyond GTM. The core principles of implementation remain the same, requiring the addition of the script, creation of triggers, and configuration of variables.
💡 Save Time In Your Setup: Scroll down this page to find a downloadable GTM recipe template. Customize it to quickly track Medallia feedback and form widget interactions on your site.
<script> (function(window) { // Define a function to handle Medallia events function handleMedalliaEvent(eventName, actionDescription, additionalKeys) { window.addEventListener(eventName, function(mdEvent) { var mdDetail = mdEvent.detail || {}; var eventData = { event: "medallia_gtm_events", medallia_action: actionDescription, medallia_form_id: mdDetail.Form_ID || null, medallia_form_type: mdDetail.Form_Type || null, medallia_feedback_uuid: mdDetail.Feedback_UUID || null, medallia_content: mdDetail.Content || null }; // Add any additional keys from the event detail if (additionalKeys && additionalKeys.length > 0) { for (var i = 0; i < additionalKeys.length; i++) { var key = additionalKeys[i]; eventData[key] = mdDetail[key] || null; } } // Push the event data to the dataLayer window.dataLayer = window.dataLayer || []; window.dataLayer.push(eventData); }); } // Set up listeners for the specified Medallia events handleMedalliaEvent('MDigital_Invite_Displayed', 'Invite displayed'); handleMedalliaEvent('MDigital_Invite_Accepted', 'Invite accepted'); handleMedalliaEvent('MDigital_Invite_Declined', 'Invite declined'); handleMedalliaEvent('MDigital_Invite_Skipped', 'Invite skipped'); handleMedalliaEvent('MDigital_ShowForm_Called', 'Form call triggered'); handleMedalliaEvent('MDigital_Button_Displayed', 'Feedback button displayed'); handleMedalliaEvent('MDigital_Form_Displayed', 'Form displayed'); handleMedalliaEvent('MDigital_Form_Page_Displayed', 'Form page displayed'); handleMedalliaEvent('MDigital_Form_Next_Page', 'Form next page'); handleMedalliaEvent('MDigital_Form_Back_Page', 'Form back page'); handleMedalliaEvent('MDigital_Form_Close_Submitted', 'Form closed after submission', ['Feedback_UUID']); handleMedalliaEvent('MDigital_Form_Close_No_Submit', 'Form closed without submission'); handleMedalliaEvent('MDigital_Submit_Feedback', 'Feedback submitted', ['Feedback_UUID', 'Content']); handleMedalliaEvent('MDigital_Feedback_Button_Clicked', 'Feedback button clicked', ['Feedback_UUID']); handleMedalliaEvent('MDigital_ThankYou_Displayed', 'Thank you displayed', ['Feedback_UUID']); handleMedalliaEvent('MDigital_ThankYou_Close', 'Thank you closed', ['Feedback_UUID']); handleMedalliaEvent('MDigital_CaptureButton_Clicked', 'Screen capture started', ['Feedback_UUID']); handleMedalliaEvent('MDigital_CaptureButton_Taken', 'Screen capture taken', ['Feedback_UUID']); handleMedalliaEvent('MDigital_CaptureButton_Cancel', 'Screen capture canceled', ['Feedback_UUID']); })(window); <script>