Last active
September 3, 2015 17:09
-
-
Save simontabor/8990a5ee829887a3e51a to your computer and use it in GitHub Desktop.
GoSquared Tracking for Wix sites (add as an iFrame widget then replace YOUR-SITE-TOKEN on line 10 with your site token)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<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