PageSourceSearch

https://www.edisaxe.com/modules/ps_googleanalytics/views/js/GoogleAnalyticActionLib.js

js edisaxe.com collected 2026-10-03 23:56:54 UTC 4,352 bytes, 170 lines download raw bytes

1/**
2 * Copyright since 2007 PrestaShop SA 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.md.
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 Since 2007 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');
80	},
81
82	removeFromCart: function(Product) {
83		this.add(Product);
84		ga('ec:setAction', 'remove');
85		ga('send', 'event', 'UX', 'click', 'Remove From cart');
86	},
87
88	addProductImpression: function(Product) {
89	},
90
91
92	refundByOrderId: function(Order) {
93		/**
94		 * Refund an entire transaction.
95		 **/
96		ga('ec:setAction', 'refund', {
97			'id': Order.id // Transaction ID is only required field for full refund.
98		});
99		ga('send', 'event', 'Ecommerce', 'Refund', {'nonInteraction': 1});
100	},
101
102	refundByProduct: function(Order) {
103		ga('ec:setAction', 'refund', {
104			'id': Order.id, // Transaction ID is required for partial refund.
105		});
106		ga('send', 'event', 'Ecommerce', 'Refund', {'nonInteraction': 1});
107	},
108
109	addProductClick: function(Product) {
110		var ClickPoint = jQuery('a[href$="' + Product.url + '"].quick-view');
111
112		ClickPoint.on("click", function() {
113			GoogleAnalyticEnhancedECommerce.add(Product);
114			ga('ec:setAction', 'click', {
115				list: Product.list
116			});
117
118			ga('send', 'event', 'Product Quick View', 'click', Product.list, {
119				'hitCallback': function() {
120					return !ga.loaded;
121				}
122			});
123		});
124
125	},
126
127	addProductClickByHttpReferal: function(Product) {
128		this.add(Product);
129		ga('ec:setAction', 'click', {
130			list: Product.list
131		});
132
133		ga('send', 'event', 'Product Click', 'click', Product.list, {
134			'nonInteraction': 1,
135			'hitCallback': function() {
136				return !ga.loaded;
137			}
138		});
139
140	},
141
142	addTransaction: function(Order) {
143		ga('ec:setAction', 'purchase', Order);
144		ga('send', 'event','Transaction','purchase', {
145			'hitCallback': function() {
146				$.get(Order.url, {
147					orderid: Order.id,
148					customer: Order.customer
149				});
150			}
151		});
152
153	},
154
155	addCheckout: function(Step) {
156		ga('ec:setAction', 'checkout', {
157			'step': Step
158			//'option':'Visa'
159		});
160		ga('send', 'pageview');
161	},
162
163	addCheckoutOption: function(Step,Option) {
164		ga('ec:setAction', 'checkout_option', {
165			'step': Step,
166			'option': Option
167		});
168		ga('send', 'event', 'Checkout', 'Option');
169  	}
170};

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.