Custom Events Setup
Custom Event Setup
Setting up a Custom Event requires adding JavaScript to your Shopify theme to trigger events at specific locations where you want to track interactions. Here’s a step-by-step example showing how to create a custom event to track a Typeform form submission.
1. Configure your test
- Create a new test in Shogun as usual.
- In the Test Goals section, select Custom event.
- Enter the event name you want to track (e.g.,
typeform_submission
). - Copy the custom event code snippet provided — you’ll use this in step 2.
2. Fire the event on your theme
- In your Shopify theme code, add a script that triggers the event name you specified.
- The exact script depends on your theme and event, so feel free to contact our Support team or your developer if you need help.
- To ensure the script runs on all relevant pages, add it to your
theme.liquid
file right above the closing</head>
tag.
Example script for Typeform form submissions (assuming you have Typeform’s Embed SDK installed):
<script>
window.addEventListener('message', function (event) {
if (event.data && event.data.type === 'form-submit') {
Shopify.analytics.publish('shogun:custom_event', {name: 'typeform_submission'});
}
});
</script>
3. Publish your test and view results
- Start your test as usual.
- Go to the test’s analytics page in the Shogun app.
- Look for the Custom Event Rate graph, which shows the percentage of sessions where your custom event fired, broken down by variant.
Please allow a few minutes for the data to appear.