Anonymous     JavaScript     05 Sep 2011    
 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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
var _gaq = _gaq || [];
_gaq.push(['_setAccount', '{{ global_settings.google_analytics_account }}']);
if(typeof(_vis_opt_GA_track) == "function") { _vis_opt_GA_track(); }
_gaq.push(['_trackPageview']);
_gaq.push(['_addTrans',
'{{ order.reference_id }}', // order ID - required
'{% if order.referral %}{{order.referral.name}}{% else %}onbekend{% endif %}', // Referral name or store name
'{{ order.price_total }}', // total - required
'0', // tax
'0', //shipping
'{{ order.city }}', // city
'', // state
'{{ order.country }}' // country
]);
// add item might be called for every item in the shopping cart
// where your ecommerce engine loops through each extras in the order
// prints out _addItem for each
_gaq.push(['_addItem',
'{{ order.reference_id }}',// order ID - required
'offer_{{ order.offer_date.offer_id }}',// SKU/code - required
'{{ order.offer_date.offer.title }}',// product name
'ground price',// category or variation
{% if not order.offer.voucher %}'{{ order.price_ground|floatformat:2 }}'{% else %}'{{ order.offer.price }}'{% endif %},// unit price - required
{% if not order.offer.voucher %}'1'{% else %}'{{ order.num_adults}}'{% endif %}// quantity - required
]);
{% if order.offer_date.offer.booking_fee %}
_gaq.push(['_addItem',
'{{ order.reference_id }}',// order ID - required
'fee',// SKU/code - required
'booking fee',// product name
'booking fee',// category or variation
'{{order.offer_date.offer.booking_fee|floatformat:2}}',// unit price - required
'1'// quantity - required
]);
{% endif %}
{% if order.payment_cost %}
_gaq.push(['_addItem',
'{{ order.reference_id }}',// order ID - required
'payment_method',// SKU/code - required
'payment method price',// product name
'payment method price',// category or variation
'{{order.payment_cost|floatformat:2}}',// unit price - required
'1'// quantity - required
]);
{% endif %}
{% ifnotequal order.extracost_singleperson 0 %}
_gaq.push(['_addItem',
'{{ order.reference_id }}',// order ID - required
'single',// SKU/code - required
'eenpersoonstoeslag',// product name
'options',// category or variation
'{{ order.extracost_singleperson|floatformat:2 }}',// unit price - required
'1'// quantity - required
]);
{% endifnotequal %}
{% for option in order.options.all %}
{% ifnotequal option.option_extracost 0 %}
_gaq.push(['_addItem',
'{{ order.reference_id }}', // id
'option_{{ option.option.id }}', // SKU
'{{ option.name }}{% ifequal option.type 'choicelist' %} {{option.choice_name}}{% else %} option{% endifequal %}', //name
'options', //cat
'{{option.option_unitprice|floatformat:2}}', // unit price
'{{ option.option_quantity }}' //quantity
]);
{% endifnotequal %}
{% endfor %}
//submits transaction to the Analytics servers
_gaq.push(['_trackTrans']);
(function() {
var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
})();