Segment
Segment is a customer data platform used to collect, route and manage website event data for analytics and marketing tools.
Segment integrates with ShopWired using a that sends website activity data to Segment, where it can be forwarded to connected destinations such as analytics platforms, CRMs and advertising tools.
Key features include:
- Website event tracking
- Centralised data collection
- Data routing to multiple destinations
- JavaScript-based implementation
Account creation
Account creation
To use Segment with ShopWired, you must have an active Segment account with a JavaScript website source created.
Once the source has been created in Segment, a JavaScript tracking snippet will be provided. This snippet is required to complete the installation on your ShopWired website.
Theme installation
Theme installation
Segment provides a JavaScript tracking snippet that should be added to your ShopWired theme so that it loads on every page of your website.
An example of the Segment JavaScript snippet is shown below:
<script> !function(){var analytics=window.analytics=window.analytics||[]; if(!analytics.initialize) if(analytics.invoked)window.console&&console.error&&console.error("Segment snippet included twice."); else{analytics.invoked=!0; analytics.methods=["track","page","identify","group","alias","ready","on","once","off"]; analytics.factory=function(t){return function(){var e=Array.prototype.slice.call(arguments); e.unshift(t);analytics.push(e);return analytics}}; for(var t=0;t<analytics.methods.length;t++){ var e=analytics.methods[t];analytics[e]=analytics.factory(e)} analytics.load=function(t,e){ var n=document.createElement("script"); n.type="text/javascript";n.async=!0; n.src="https://cdn.segment.com/analytics.js/v1/"+t+"/analytics.min.js"; var a=document.getElementsByTagName("script")[0]; a.parentNode.insertBefore(n,a);analytics._loadOptions=e}; analytics.SNIPPET_VERSION="4.15.3"; analytics.load("WRITE_KEY"); analytics.page();}}(); </script>
The script shown above is provided as an example only. You must copy the exact script provided in your own account, as the script and any ID values will be unique to your website.
To add the Segment tracking snippet sitewide:
- Navigate to Website > Themes
- Select the
code editoroption for the theme you want to edit - Open the
master.twigfile - Paste the Segment snippet just before the closing
</head>tag
Verifying the installation
Verifying the installation
Once the Segment JavaScript snippet has been added to your ShopWired website, visit your website in a new browser tab to trigger page view events.
If the snippet is loading correctly, Segment will begin receiving website activity data from your ShopWired store.
Recommendations
Recommendations
- Add the Segment JavaScript snippet to your ShopWired theme so it loads consistently across all pages of your website
- Avoid adding the snippet multiple times, as this can result in duplicated tracking data
- Confirm the snippet remains in place when switching or updating themes