How to Create GTM Triggers to Measure Shipping Method Preferences on Wix

Hey, it’s Deviate Tracking here! If you’re running an online store on Wix, it’s crucial to gather data about your customer preferences to optimize your shopping experience. One important aspect of this data is your customers’ preferred shipping methods. In this tutorial, I’ll walk you through creating Google Tag Manager (GTM) triggers to measure shipping method preferences on your Wix website. Ready? Let’s dive in!

Step 1: Create a new Custom Event Trigger

First, we need to create a trigger in Google Tag Manager that will fire when a customer selects their preferred shipping method during the checkout process.

1. Log in to your Google Tag Manager account and click on your Wix container.
2. Go to “Triggers” on the left sidebar and click “New.”
3. Name the trigger “Shipping Method Selected.”
4. Choose “Custom Event” as the trigger type.
5. For the event name, enter “shippingMethodSelected.”
6. Set the trigger to fire on “All Custom Events.”
7. Save the trigger.

This newly created trigger will fire whenever the “shippingMethodSelected” event is triggered on your Wix website.

Step 2: Add JavaScript code to your Wix website

Next, we need to add the JavaScript code to your Wix website that will send the shipping method value to GTM when the customer selects their preferred shipping option during checkout. Here’s the code snippet:

<script>
// Run this script when the DOM is ready
document.addEventListener('DOMContentLoaded', () => {
// Query the document for the shipping method select element
const shippingSelect = document.querySelector('#shipping_method_select');

// Listen for the change event on the select element
shippingSelect.addEventListener('change', (event) => {
// Get the selected shipping method value
const selectedShippingMethod = event.target.value;

// Push the value to GTM via the dataLayer
dataLayer.push({
event: 'shippingMethodSelected',
shippingMethod: selectedShippingMethod,
});
});
});</script>

To add this code to your Wix Website, follow these steps:

1. In your Wix editor, go to “Settings” and click “Tracking & Analytics.”
2. Click “New Tool” and select “Custom.”
3. Paste the JavaScript code provided above into the “Paste the code snippet here” box.
4. Choose “Load code once” and select the ” ” location option.
5. Name the tool “Shipping Method Tracker.”
6. Enable the “All Pages” option and click “Apply.”

For your JavaScript code to work, make sure you already have the GTM container tracking code installed on your Wix website.

Step 3: Create a new Data Layer Variable

Now, we need to create a new Data Layer Variable in GTM to store the selected shipping method value.

1. In your GTM container, go to “Variables” on the left sidebar and click “New.”
2. Name the variable “Selected Shipping Method.”
3. Choose “Data Layer Variable” as the variable type.
4. For the Data Layer Variable Name, enter “shippingMethod.”
5. Save the variable.

Step 4: Create a new Google Analytics Event Tag

Finally, we need to create a new Google Analytics Event Tag to track the “shippingMethodSelected” event and the corresponding shipping method value.

1. In your GTM container, go to “Tags” on the left sidebar and click “New.”
2. Name the tag “GA – Event – Shipping Method Selected.”
3. Choose “Google Analytics: Universal Analytics” as the tag type.
4. Set the Track Type to “Event.”
5. For “Category,” enter “Checkout.”
6. For “Action,” enter “Shipping Method Selected.”
7. For “Label,” click the variable icon “{{ }}” and select the “Selected Shipping Method” variable that you created in Step 3.
8. Choose your Google Analytics Settings Variable or enter your tracking ID manually.
9. In the “Triggering” section, click the pencil icon and select the “Shipping Method Selected” trigger that you created in Step 1.
10. Save the tag.

Conclusion

Great job! You have now successfully configured your Wix Website to track your customers’ preferred shipping methods using Google Tag Manager. Analyze this data in your Google Analytics dashboard to better understand customer preferences, enhance the shopping experience, and increase conversions. Good luck, and happy tracking!