File: plugin/ga_adapter/

Recommend this page to a friend!
  Classes of Arturs Sosins   Countly Web SDK   plugin/ga_adapter/   Download  
File: plugin/ga_adapter/
Role: Example script
Content type: text/markdown
Description: Example script
Class: Countly Web SDK
Track site accesses and errors the Countly API
Author: By
Last change: Update of plugin/ga_adapter/
Date: 1 year ago
Size: 2,571 bytes


Class file image Download

Countly Google Analytics Adapter

What's Countly Google Analytics Adapter?

Countly Google Analytics Adapter is a migration tool for your web apps which has already implemented Google Analytics trackers, you can easily send your analytics data to your Countly instance too without any extra integration.

Implementing Countly Google Analytics Adapter in your web pages

There are only two step for integration.

1. Add Countly Web SDK integration snippet into your web page

<script type='text/javascript'>
// Some default pre init
var Countly = Countly || {};
Countly.q = Countly.q || [];
Countly.onload = Countly.onload || [];

// Provide your app key that you retrieved from Countly dashboard
Countly.app_key = "YOUR_APP_KEY";

// Provide your server IP or name. Use or 
// or for EE trial server.
// If you use your own server, make sure you have https enabled if you use
// https below.
Countly.url = ""; 

// Start pushing function calls to queue
// Track sessions automatically (recommended)
//track web page views automatically (recommended)
// Uncomment the following line to track web heatmaps (Enterprise Edition)
// Countly.q.push(['track_clicks']);

// Uncomment the following line to track web scrollmaps (Enterprise Edition)
// Countly.q.push(['track_scrolls']);
// 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 = '';
	cly.onload = function(){Countly.init()};
	var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(cly, s);

2. Change your Google Analytics integration code like below

(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),

// add this line into your google analytics snippet

ga('create', 'UA-56295140-3', 'auto');


That's all. Now you can track your app from your Countly instance too.