Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
GoSquared Tracking for Wix sites (add as an iFrame widget then replace YOUR-SITE-TOKEN on line 10 with your site token)
<html>
<head>
<script src="//sslstatic.wix.com/services/js-sdk/1.43.0/js/wix.min.js"></script>
<script>
!function(g,s,q,r,d){r=g[r]=g[r]||function(){(r.q=r.q||[]).push(
arguments)};d=s.createElement(q);q=s.getElementsByTagName(q)[0];
d.src='//d1l6p2sc9645hc.cloudfront.net/tracker.js';q.parentNode.
insertBefore(d,q)}(window,document,'script','_gs');
_gs('YOUR-SITE-TOKEN', false);
_gs('set', 'trackHash', true);
var url;
var checkTrack = function() {
Wix.getSiteInfo(function(site) {
if (site.url === url) return;
if (!url) {
_gs('set', 'referrer', site.referrer);
_gs('set', 'cookieDomain', (function(h){
var a = document.createElement('a');
a.href = h;
return a.host;
})(site.baseUrl));
}
url = site.url;
_gs('track', url, site.pageTitle);
});
};
Wix.addEventListener(Wix.Events.PAGE_NAVIGATION, checkTrack);
setInterval(checkTrack, 1000);
checkTrack();
</script>
</head>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.