Skip to content

Commit

Permalink
Merge pull request #33 from Countly/next
Browse files Browse the repository at this point in the history
Next
  • Loading branch information
ar2rsawseen authored Nov 12, 2018
2 parents 387f6d3 + c15d5e8 commit 534c738
Show file tree
Hide file tree
Showing 22 changed files with 1,950 additions and 334 deletions.
1 change: 1 addition & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ script:
- casperjs test test/tests_sync.js
- casperjs test test/tests_async.js
- casperjs test test/tests_helpers.js
- casperjs test test/tests_helpers_old_session.js
- casperjs test test/tests_gdpr.js
- casperjs test test/tests_persistancy.js
after_success:
Expand Down
92 changes: 46 additions & 46 deletions examples/example_async.html
Original file line number Diff line number Diff line change
@@ -1,46 +1,46 @@
<html>
<head>
<script type='text/javascript'>
//some default pre init
var Countly = Countly || {};
Countly.q = Countly.q || [];

//provide countly initialization parameters
Countly.app_key = "YOUR_APP_KEY";
Countly.url = "https://try.count.ly"; //your server goes here
Countly.debug = true;

//start pushing function calls to queue
//track sessions automatically
Countly.q.push(['track_sessions']);

//track sessions automatically
Countly.q.push(['track_pageview']);

//load countly script asynchronously
(function() {
var cly = document.createElement('script'); cly.type = 'text/javascript';
cly.async = true;
//enter url of script here
cly.src = '../lib/countly.min.js';
cly.onload = function(){Countly.init()};
var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(cly, s);
})();
</script>
</head>
<body>
<script type='text/javascript'>
//send event on button click
function clickEvent(ob){
Countly.q.push(['add_event',{
key:"buttonClick",
"segmentation": {
"id": ob.id
}
}]);
}
</script>
<input type="button" id="testButton" onclick="clickEvent(this)" value="Test Button">
<p><a href='http://count.ly/'>Count.ly</a></p>
</body>
</html>
<html>
<head>
<script type='text/javascript'>
//some default pre init
var Countly = Countly || {};
Countly.q = Countly.q || [];

//provide countly initialization parameters
Countly.app_key = "YOUR_APP_KEY";
Countly.url = "https://try.count.ly"; //your server goes here
Countly.debug = true;

//start pushing function calls to queue
//track sessions automatically
Countly.q.push(['track_sessions']);

//track sessions automatically
Countly.q.push(['track_pageview']);

//load countly script asynchronously
(function() {
var cly = document.createElement('script'); cly.type = 'text/javascript';
cly.async = true;
//enter url of script here
cly.src = '../lib/countly.js';
cly.onload = function(){Countly.init()};
var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(cly, s);
})();
</script>
</head>
<body>
<script type='text/javascript'>
//send event on button click
function clickEvent(ob){
Countly.q.push(['add_event',{
key:"buttonClick",
"segmentation": {
"id": ob.id
}
}]);
}
</script>
<input type="button" id="testButton" onclick="clickEvent(this)" value="Test Button">
<p><a href='http://count.ly/'>Count.ly</a></p>
</body>
</html>
2 changes: 1 addition & 1 deletion examples/example_fb.html
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<html>
<head>
<!--Countly script-->
<script type='text/javascript' src='../lib/countly.min.js'></script>
<script type='text/javascript' src='../lib/countly.js'></script>
<script type='text/javascript'>

//initializing countly with params
Expand Down
2 changes: 1 addition & 1 deletion examples/example_formdata.html
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<html>
<head>
<!--Countly script-->
<script type='text/javascript' src='../lib/countly.min.js'></script>
<script type='text/javascript' src='../lib/countly.js'></script>
<script type='text/javascript'>

//initializing countly with params
Expand Down
172 changes: 172 additions & 0 deletions examples/example_ga_adapter.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,172 @@
<html>
<head>
<script type='text/javascript'>
//some default pre init
var Countly = Countly || {};
Countly.q = Countly.q || [];
Countly.onload = Countly.onload || [];
//provide countly initialization parameters
Countly.app_key = "YOUR_APP_KEY";
Countly.url = "https://try.count.ly"; //your server goes here
window.cly_ga_test_mode = true;
Countly.test_logs = [];
//start pushing function calls to queue
//track sessions automatically


//load countly script asynchronously
(function() {
var cly = document.createElement('script'); cly.type = 'text/javascript';
cly.async = true;
//enter url of script here
cly.src = '../lib/countly.min.js';
cly.onload = function(){Countly.init()};
var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(cly, s);
})();
</script>
<script src="../plugin/ga_adapter/ga_adapter.js"></script>
<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');

Countly.onload.push(function() {
CountlyGAAdapter();
// call create call with ga id
ga('create', 'UA-56295140-3', 'auto');

// call create with function
ga('create', 'UA-56295140-3', function() {
return true;
});

// send pageview
ga('send', 'pageview');

// send pageview with page field
ga('send', 'pageview', 'test-page.html');

// send pageview with custom dimension
ga('send', 'pageview', {customDimension:'customValue'});

// send social
ga('send', 'social', 'network', 'action', 'target');

// send screenview
ga('send', 'screenview', {'appName':'application1'});

// send exception
ga('send', 'exception', {exDescription:'errorDescription', exFatal:false});

// send event with hitType object, with label and value
ga('send', {hitType:'event', eventCategory: 'category', eventAction:'action', eventLabel: 'label', eventValue:2 });

// send event with hitType object, without value with label
ga('send', {hitType:'event', eventCategory: 'category', eventAction:'action', eventLabel: 'label'});

// send event with hitType object, without label and with value
ga('send', {hitType:'event', eventCategory: 'category', eventAction:'action', eventValue:2});

// send event with hitType object, without label and value
ga('send', {hitType:'event', eventCategory: 'category', eventAction:'action'});

// send social with hitType object
ga('send', {hitType:'social', socialNetwork: 'network', socialAction: 'like', socialTarget: 'target'});

// send timing with hitType object
ga('send', {hitType:'timing', timingCategory: 'category', timingVar: 'load', timingValue: 3549});

// send timing without hitType object
ga('send', 'timing', 'category', 'load', 3549);

// send timing without hitType object with label
ga('send', 'timing', 'category', 'load', 3549, 'timinglabel');

// send pageview with hitType object
ga('send', {hitType:'pageview', page: 'page.html'});

// set page
ga('set', 'page', 'randompage.html');

// send pageview after set page
ga('send', 'pageview');

// set custom data
ga('set', 'dimension', 'customdimension');

// set custom data as object
ga('set', {'key':'value', 'anotherKey':'anotherValue'});

// add ecommerce transaction without currency
ga('ecommerce:addTransaction', {
'id': '1234', // Transaction ID. Required.
'affiliation': 'Acme Clothing', // Affiliation or store name.
'revenue': '11.99', // Grand Total.
'shipping': '5', // Shipping.
'tax': '1.29' // Tax.
});

// add ecommerce transcation with currency
ga('ecommerce:addTransaction', {
'id': '1234',
'affiliation': 'Acme Clothing',
'revenue': '11.99',
'shipping': '5',
'tax': '1.29',
'currency': 'EUR' // local currency code.
});

// add item without currency
ga('ecommerce:addItem', {
'id': '1234', // Transaction ID. Required.
'name': 'Fluffy Pink Bunnies', // Product name. Required.
'sku': 'DD23444', // SKU/code.
'category': 'Party Toys', // Category or variation.
'price': '11.99', // Unit price.
'quantity': '5' // Quantity.
});

// add item with currency
ga('ecommerce:addItem', {
'id': '1234',
'name': 'Fluffy Pink Bunnies',
'sku': 'DD23444',
'category': 'Party Toys',
'price': '11.99',
'quantity': '5',
'currency': 'GBP' // local currency code.
});

// clear ecommerce cart
ga('ecommerce:clear');

// add item with currency again
ga('ecommerce:addItem', {
'id': '1234',
'name': 'Fluffy Pink Bunnies',
'sku': 'DD23444',
'category': 'Party Toys',
'price': '11.99',
'quantity': '5',
'currency': 'GBP' // local currency code.
});

// send ecommerce cart
ga('ecommerce:send');

// send event without label, without value
ga('send', 'event', 'category', 'action');

// send event without value, with label
ga('send', 'event', 'category', 'action', 'label');

// send event with label and value
ga('send', 'event', 'category', 'action', 'label', 3);

});
</script>
</head>
<body>
</body>
</html>
Loading

0 comments on commit 534c738

Please sign in to comment.