PageSourceSearch

https://www.fietsgoed.nl/modules/ps_googleanalytics/views/js/GoogleAnalyticActionLib.js

js fietsgoed.nl collected 2026-10-08 21:33:26 UTC 4,583 bytes, 180 lines download raw bytes

1/**
2 * 2007-2020 PrestaShop and Contributors
3 *
4 * NOTICE OF LICENSE
5 *
6 * This source file is subject to the Academic Free License 3.0 (AFL-3.0)
7 * that is bundled with this package in the file LICENSE.txt.
8 * It is also available through the world-wide-web at this URL:
9 * https://opensource.org/licenses/AFL-3.0
10 * If you did not receive a copy of the license and are unable to
11 * obtain it through the world-wide-web, please send an email
12 * to [email protected] so we can send you a copy immediately.
13 *
14 * @author    PrestaShop SA <[email protected]>
15 * @copyright 2007-2020 PrestaShop SA and Contributors
16 * @license   https://opensource.org/licenses/AFL-3.0 Academic Free License 3.0 (AFL-3.0)
17 * International Registered Trademark & Property of PrestaShop SA
18 */
19
20/* globals $, ga, jQuery */
21
22var GoogleAnalyticEnhancedECommerce = {
23
24	setCurrency: function(Currency) {
25		ga('set', '&cu', Currency);
26	},
27
28	add: function(Product, Order, Impression) {
29		var Products = {};
30		var Orders = {};
31
32		var ProductFieldObject = ['id', 'name', 'category', 'brand', 'variant', 'price', 'quantity', 'coupon', 'list', 'position', 'dimension1'];
33		var OrderFieldObject = ['id', 'affiliation', 'revenue', 'tax', 'shipping', 'coupon', 'list', 'step', 'option'];
34
35		if (Product != null) {
36			if (Impression && Product.quantity !== undefined) {
37				delete Product.quantity;
38			}
39
40			for (var productKey in Product) {
41				for (var i = 0; i < ProductFieldObject.length; i++) {
42					if (productKey.toLowerCase() == ProductFieldObject[i]) {
43						if (Product[productKey] != null) {
44							Products[productKey.toLowerCase()] = Product[productKey];
45						}
46
47					}
48				}
49
50			}
51		}
52
53		if (Order != null) {
54			for (var orderKey in Order) {
55				for (var j = 0; j < OrderFieldObject.length; j++) {
56					if (orderKey.toLowerCase() == OrderFieldObject[j]) {
57						Orders[orderKey.toLowerCase()] = Order[orderKey];
58					}
59				}
60			}
61		}
62
63		if (Impression) {
64			ga('ec:addImpression', Products);
65		} else {
66			ga('ec:addProduct', Products);
67		}
68	},
69
70	addProductDetailView: function(Product) {
71		this.add(Product);
72		ga('ec:setAction', 'detail');
73		ga('send', 'event', 'UX', 'detail', 'Product Detail View',{'nonInteraction': 1});
74	},
75
76	addToCart: function(Product) {
77		this.add(Product);
78		ga('ec:setAction', 'add');
79		ga('send', 'event', 'UX', 'click', 'Add to Cart'); // Send data using an event.
80	},
81
82	removeFromCart: function(Product) {
83		this.add(Product);
84		ga('ec:setAction', 'remove');
85		ga('send', 'event', 'UX', 'click', 'Remove From cart'); // Send data using an event.
86	},
87
88	addProductImpression: function(Product) {
89		//ga('send', 'pageview');
90	},
91
92	/**
93	id, type, affiliation, revenue, tax, shipping and coupon.
94	**/
95	refundByOrderId: function(Order) {
96		/**
97		 * Refund an entire transaction.
98		 **/
99		ga('ec:setAction', 'refund', {
100			'id': Order.id // Transaction ID is only required field for full refund.
101		});
102		ga('send', 'event', 'Ecommerce', 'Refund', {'nonInteraction': 1});
103	},
104
105	refundByProduct: function(Order) {
106		/**
107		 * Refund a single product.
108		 **/
109		//this.add(Product);
110
111		ga('ec:setAction', 'refund', {
112			'id': Order.id, // Transaction ID is required for partial refund.
113		});
114		ga('send', 'event', 'Ecommerce', 'Refund', {'nonInteraction': 1});
115	},
116
117	addProductClick: function(Product) {
118		var ClickPoint = jQuery('a[href$="' + Product.url + '"].quick-view');
119
120		ClickPoint.on("click", function() {
121			GoogleAnalyticEnhancedECommerce.add(Product);
122			ga('ec:setAction', 'click', {
123				list: Product.list
124			});
125
126			ga('send', 'event', 'Product Quick View', 'click', Product.list, {
127				'hitCallback': function() {
128					return !ga.loaded;
129				}
130			});
131		});
132
133	},
134
135	addProductClickByHttpReferal: function(Product) {
136		this.add(Product);
137		ga('ec:setAction', 'click', {
138			list: Product.list
139		});
140
141		ga('send', 'event', 'Product Click', 'click', Product.list, {
142			'nonInteraction': 1,
143			'hitCallback': function() {
144				return !ga.loaded;
145			}
146		});
147
148	},
149
150	addTransaction: function(Order) {
151
152		//this.add(Product);
153		ga('ec:setAction', 'purchase', Order);
154		ga('send', 'event','Transaction','purchase', {
155			'hitCallback': function() {
156				$.get(Order.url, {
157					orderid: Order.id,
158					customer: Order.customer
159				});
160			}
161		});
162
163	},
164
165	addCheckout: function(Step) {
166		ga('ec:setAction', 'checkout', {
167			'step': Step
168			//'option':'Visa'
169		});
170		ga('send', 'pageview');
171	},
172
173	addCheckoutOption: function(Step,Option) {
174		ga('ec:setAction', 'checkout_option', {
175			'step': Step,
176			'option': Option
177		});
178		ga('send', 'event', 'Checkout', 'Option');
179  	}
180};

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.