Retention Science - JavaScript Tracking For Shopify
Getting Started ¶
What is JavaScript used for?
JavaScript (JS) is used for event tracking in real-time. Google defines an event as "user interactions with content that can be tracked independently from a web page or a screen load."
By implementing our JS snippets on your webpages, you are able to track several standard events, as well as custom (user-defined) events on your webpages. These JS snippets should be inserted before the closing </head> tag of each page in which you are tracking an event.
How does Cortex use JavaScript tracking?
Retention Science's event tracking serves as the "food" for our AI models, enabling us to learn how users are engaging with your website and what types of campaigns/recommendations/subject lines will work best for them.
Whether you are using Shopify, Magento, or custom HTML scripts, this guide will help you understand our JavaScript event tracking and key details. (You can also watch our YouTube videos for similar explanations of data, JS, and other topics)
How to Implement our JavaScript
- Follow these instructions to implement our tracking pixel on your Shopify store.
- The only time a Shopify client has to do anything additional is when customizations are made to the site outside of Shopify
- e.g. Search Bar is added via third-party plugin, and you will want to fire our search event to power our Search Abandon campaign.
- e.g. Capture forms will need to fire our email capture via JS or User API
How does ReSci Prioritize Site Performance?
Our JavaScript optimizes for your website performance by utilizing:
- Asynchronous script loading to ensure the script does not interfere with page loading or affect site speed.
- Content Delivery Network (CDN) hosting to ensure low latency and high data transfer speeds.
- Code encapsulation is an anonymous function so it does not interfere with any external JavaScript Variables.
User Interaction Events 101 ¶
JavaScript Events Overview
Events are user interactions with your website that are being tracked by our various JavaScript snippets. ReSci tracks a number of standard events by default. In addition to standard events, custom (user-defined) events are also supported.
All of the JS events work in a similar fashion, and share certain commonalities across the various events.
If you followed these instructions correctly, then you will cover most of the events needed to power Cortex.
Optional JavaScript Events Not Covered in Shopify Setup Instructions
Commonalities across all JS events
- There is a static site ID that is always a string unique to your site, this will be provided during your Onboarding Kickoff call.
- There is always an "if" condition to analyze if a user is logged in or not, and if they are you should add the user_id or email value in the wave as indicated in the code examples.
- Only one is needed to ID the user.
- We do cookie track users, so users that have browsed anonymously will have past actions associated automatically if they ever log in or click on an email and land onsite.
- There is always a final "track" code line (static) which causes the event to be tracked.
- There is always the immediately invoked function at the end of each script which is required for the JS tracking to work.