Skip to content

Instantly share code, notes, and snippets.

@frknbasaran
Last active October 5, 2018 14:43
Show Gist options
  • Save frknbasaran/eb812c9dc83f2b7f761daf4b6e0c19b7 to your computer and use it in GitHub Desktop.
Save frknbasaran/eb812c9dc83f2b7f761daf4b6e0c19b7 to your computer and use it in GitHub Desktop.
Send your data to Countly with GA methods.
<!DOCTYPE html>
<html>
<body>
<!-- Countly Web SDK Initialization -->
<script type="text/javascript">
// Some default pre init
var Countly = {};
Countly.q = Countly.q || [];
// Provide your app key that you retrieved from Countly dashboard
Countly.app_key = "app_key";
// Provide your server IP or name. Use try.count.ly or us-try.count.ly
// or asia-try.count.ly for EE trial server.
// If you use your own server, make sure you have https enabled if you use
// https below.
Countly.url = "countly_url";
// Load Countly script asynchronously
(function() {
var cly = document.createElement('script'); cly.type = 'text/javascript';
cly.async = true;
// Enter url of script here (see below for other option)
cly.src = 'https://rawgit.com/Countly/countly-sdk-web/master/lib/countly.js';
cly.onload = function(){Countly.init();};
var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(cly, s);
})();
</script>
<!-- END of Countly Web SDK Initialization -->
<!-- Converter Library. Should inject after Countly Web SDK Initialization -->
<script src="converter.js"></script>
<!-- END of Converter Library -->
<!-- Google Analytics -->
<script>
(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
})(window,document,'script','https://www.google-analytics.com/analytics.js','ga');
// just add this line
CountlyGAListener();
ga('create', 'UA-56295140-3', 'auto');
ga('send', 'pageview');
</script>
<!-- End Google Analytics -->
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment