PageSourceSearch

https://www.golfshopen.no/static/version1790852184/frontend/Bluemint/golfshopen/nb_NO/Anowave_Ec4/js/ec4.js

js golfshopen.no collected 2026-10-06 07:19:33 UTC 3,516 bytes, 140 lines download raw bytes

1if ('undefined' !== typeof AEC && 'undefined' !== typeof AEC.EventDispatcher)
2{
3	AEC.GA4 = (() =>
4	{
5		return {
6			enabled: false,
7			transformCategories: function(category)
8			{
9				if (null === category)
10				{
11					return {};
12				}
13
14				let map = {}, categories = category.toString().split('/');
15
16				if (categories)
17				{
18					map['item_category'] = categories.shift();
19
20					if (categories.length)
21					{
22						let index = 1;
23
24						categories.forEach(category =>
25						{
26							map['item_category' + (++index)] = category;
27						});
28					}
29				}
30
31				return map;
32			},
33			augmentCategories: function(product)
34			{
35				if (product.hasOwnProperty('category'))
36				{
37					AEC.Cookie.augment([product]);
38				}
39
40				return this.transformCategories(product.category);
41			},
42			augmentItem: function(product)
43			{
44				let map = {};
45
46				map['google_business_vertical'] = 'retail';
47
48				Object.entries(product).forEach(([key, value]) =>
49				{
50					if (-1 === ['id','name','price','category','currency','variant','brand'].indexOf(key))
51					{
52						map[key] = value;
53					}
54				});
55
56				return map;
57			}
58
59		}
60	})();
61
62	/**
63	 * Modify checkout step option payloasd
64	 */
65	AEC.EventDispatcher.on('ec.checkout.step.option.data', data =>
66	{
67		if (!AEC.GA4.enabled)
68		{
69			return true;
70		}
71
72		switch(parseInt(data.ecommerce.checkout_option.actionField.step))
73		{
74			case AEC.Const.CHECKOUT_STEP_SHIPPING:
75
76				data['event'] = 'add_shipping_info';
77
78				if (AEC.GA4.quote.hasOwnProperty('coupon'))
79				{
80					data.ecommerce['coupon'] = AEC.GA4.quote.coupon;
81				}
82
83				data.ecommerce['currency'] = AEC.GA4.currency;
84
85                if (AEC.Checkout.getPayload().ecommerce !== undefined && AEC.Checkout.getPayload().ecommerce.hasOwnProperty('items')) {
86                    data.ecommerce['items'] = AEC.Checkout.getPayload().ecommerce.items;
87                } else if (AEC.Checkout.data.ecommerce.items !== undefined) {
88                    data.ecommerce['items'] = AEC.Checkout.data.ecommerce.items;
89                }
90
91                data.ecommerce['shipping_tier'] = data.ecommerce.checkout_option.actionField.option;
92
93                if (data.ecommerce['items'] !== undefined) {
94                    (data => {
95                        let value = 0;
96
97                        data.ecommerce['items'].forEach(item => {
98                            value += Number(item.price) * Number(item.quantity);
99                        });
100
101                        data.ecommerce['value'] = value;
102
103                    })(data);
104                }
105                delete data.ecommerce.checkout_option;
106
107                break;
108
109            case AEC.Const.CHECKOUT_STEP_PAYMENT:
110
111                data['event'] = 'add_payment_info';
112
113                if (AEC.GA4.quote.hasOwnProperty('coupon')) {
114                    data.ecommerce['coupon'] = AEC.GA4.quote.coupon;
115                }
116
117                data.ecommerce['currency'] = AEC.GA4.currency;
118
119                data.ecommerce['items'] = AEC.Checkout.getPayload().ecommerce.items;
120
121                data.ecommerce['payment_type'] = data.ecommerce.checkout_option.actionField.option;
122
123                (data => {
124                    let value = 0;
125
126                    data.ecommerce['items'].forEach(item => {
127                        value += Number(item.price) * Number(item.quantity);
128                    });
129
130                    data.ecommerce['value'] = value;
131
132                })(data);
133
134
135                delete data.ecommerce.checkout_option;
136
137                break;
138        }
139    });
140}

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.