gkdAnalyticsGa.js
1.2 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
function gkdEctTrack(action, pid, desc) {
var async = action == 'remove' ? false : true;
$.ajax({
url: 'index.php?route=geekodev/analytics/getTrackData',
type: 'post', dataType: 'json', cache: false, async: async,
data: {pid: pid, action: action},
success: function(res) {
if (typeof res[0] !== 'undefined') {
ga('ec:addProduct', res[0]);
ga('ec:setAction', action);
ga('send', 'event', $(document).find('title').text(), desc, res[0].name);
}
}
});
}
function gkdEctTrackCheckout(step, desc) {
if (typeof jQuery != 'undefined') {
$.ajax({
url: 'index.php?route=geekodev/analytics/getTrackData',
type: 'post', dataType: 'json', cache: false,
data: {cart:1},
success: function(res) {
for(var i=0; i<res.length; i++) {
if (typeof res[i] !== 'undefined') {
ga('ec:addProduct', res[i]);
}
}
ga('ec:setAction', 'checkout', {'step':step, 'option':desc});
ga('send', 'pageview');
}
});
}
}
if (typeof jQuery != 'undefined') {
$(document).delegate('#button-confirm', 'click', function(){
gkdEctTrackCheckout(3, 'Checkout confirm');
});
}