PageSourceSearch

https://arcaamsterdam.nl/wp-content/themes/arca-theme-2021/functio…/js/capi-tracking.js?debug=1791290533

js arcaamsterdam.nl collected 2026-10-06 12:46:55 UTC 6,676 bytes, 256 lines download raw bytes

1jQuery(document).ready(function ($) {
2	console.log('CAPI ready');
3
4	/**
5	 * Generate event IDs
6	 */
7	function getEventID() {
8		var result = [];
9		var characters = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789';
10		var charactersLength = characters.length;
11		for (var i = 0; i < 23; i++) {
12			result.push(characters.charAt(Math.floor(Math.random() * charactersLength)));
13		}
14		return result.join('');
15	}
16
17	/**
18	 * Get fb cookie values
19	 */
20	function getCookie(name) {
21		var nameEQ = name + '=';
22		var ca = document.cookie.split(';');
23		for (var i = 0; i < ca.length; i++) {
24			var c = ca[i];
25			while (c.charAt(0) == ' ') c = c.substring(1, c.length);
26			if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length, c.length);
27		}
28		return null;
29	}
30
31	/**
32	 * AddToCart Event
33	 */
34	// if (scriptVars.addToCartTrigger) {
35	// 	var addToCartTrigger = jQuery(scriptVars.addToCartTrigger);
36	// 	addToCartTrigger.on('click', function () {
37	// 		// Fuse-only delivery datepicker check
38	// 		if ($('.delivery-datepicker').length && $('.delivery-datepicker').val() == false) {
39	// 			return;
40	// 		}
41
42	// 		// Get quantity
43	// 		var quantity = 1;
44	// 		if ($('.qty').length) {
45	// 			quantity = $('.qty').val();
46	// 		}
47
48	// 		$.ajax({
49	// 			type: 'POST',
50	// 			url: scriptVars.ajaxUrl,
51	// 			dataType: 'html',
52	// 			data: {
53	// 				product_id: addToCartTrigger.attr('value'),
54	// 				quantity: quantity,
55	// 				event_source: window.location.href,
56	// 				fbp: getCookie('_fbp'),
57	// 				fbc: getCookie('_fbc'),
58	// 				action: 'send_AddToCart_event',
59	// 			},
60	// 			error: function (err) {
61	// 				console.log(err);
62	// 			},
63	// 		});
64	// 	});
65	// }
66
67	/**
68	 * InitiateCheckout Event
69	 */
70	// if (scriptVars.initiateCheckoutTrigger) {
71	// 	var initiateCheckoutTrigger = jQuery(scriptVars.initiateCheckoutTrigger);
72	// 	initiateCheckoutTrigger.on('click', function () {
73	// 		$.ajax({
74	// 			type: 'POST',
75	// 			url: scriptVars.ajaxUrl,
76	// 			dataType: 'html',
77	// 			data: {
78	// 				event_source: window.location.href,
79	// 				fbp: getCookie('_fbp'),
80	// 				fbc: getCookie('_fbc'),
81	// 				action: 'send_InitiateCheckout_event',
82	// 			},
83	// 			error: function (err) {
84	// 				console.log(err);
85	// 			},
86	// 		});
87	// 	});
88	// }
89
90	/**
91	 * AJAX setup to send a basic event
92	 *
93	 * Used for misc click events, form submits, etc where
94	 * it's not needed to pass any data other than the event name.
95	 */
96	function basicEventAjax(eventName) {
97		// Send Pixel event
98		const eventID = getEventID();
99		fbq('track', eventName, {}, { eventID: eventID });
100
101		const data = {
102			event_name: eventName,
103			event_source: window.location.href,
104			event_id: eventID,
105			action: 'send_basic_event',
106		};
107
108		if (getCookie('_fbp')) data.fbp = getCookie('_fbp');
109		if (getCookie('_fbc')) data.fbc = getCookie('_fbc');
110
111		// Send CAPI event
112		$.ajax({
113			type: 'POST',
114			url: scriptVars.ajaxUrl,
115			dataType: 'html',
116			data: data,
117			success: function (response) {
118				console.log("Event '" + eventName + "' sent.");
119				// console.log(response);
120			},
121			error: function (err) {
122				console.log(err);
123			},
124		});
125	}
126
127	/**
128	 * AJAX setup to send a Purchase event
129	 *
130	 */
131	function purchaseEventAjax(eventName, eventDetails) {
132		// Send Pixel event
133		const eventID = getEventID();
134		fbq('track', eventName, {}, { eventID: eventID });
135
136		const data = {
137			event_name: eventName,
138			event_source: window.location.href,
139			event_id: eventID,
140			products: JSON.stringify(eventDetails.order.products),
141			value: eventDetails.order.totalAmount,
142			currency: 'EUR',
143			action: 'send_Purchase_event',
144		};
145
146		if (getCookie('_fbp')) data.fbp = getCookie('_fbp');
147		if (getCookie('_fbc')) data.fbc = getCookie('_fbc');
148
149		// Send CAPI event
150		$.ajax({
151			type: 'POST',
152			url: scriptVars.ajaxUrl,
153			dataType: 'html',
154			data: data,
155			success: function (response) {
156				console.log("Purchase Event '" + eventName + "' sent.");
157				// console.log(response);
158			},
159			error: function (err) {
160				console.log(err);
161			},
162		});
163	}
164
165	/*
166	 * Add any custom events here
167	 ****************************/
168
169	// Copy/Paste Examples
170	// $('#digi-click-id').on('click', function() {
171	//     basicEventAjax('MyCustomEventName');
172	// })
173
174	// $('.form-selector').on('submit', function() {
175	//     basicEventAjax('MyCustomEventName');
176	// })
177
178	// $(window.location.href.indexOf('the-tracked-url-path') != -1) {
179	//     basicEventAjax('MyCustomEventName')
180	// }
181
182	// Track click on particular link
183	// $('a[href*="mywebsite.com"]').on('click', function () {
184	// 	basicEventAjax('MyCustomEventName');
185	// });
186
187	// Track form submission
188	// $(document).on('submit', '.my-form-class__container .my-form-class__form', (e) => {
189	// 	e.preventDefault();
190	// 	basicEventAjax('MyCustomEventName');
191	// });
192
193	// Track click on a link on a particular URL only
194	// if ($(window.location.href.indexOf('my-url') != -1)) {
195	// 	$('a[href*="tel:"]').on('click', function () {
196	// 		basicEventAjax('MyCustomEventName');
197	// 	});
198	// }
199
200	// PageView event
201	$(document).ready(function () {
202		basicEventAjax('PageView');
203	});
204
205	// Track Menu View (assuming all the pdfs on the website are just menus)
206	$('a[href$=".pdf"]').on('click', function () {
207		basicEventAjax('View Menu');
208	});
209
210	// Contact phone event
211	$('a[href*="tel:"]').on('click', function () {
212		basicEventAjax('Contact - Phone');
213	});
214
215	// Contact email event
216	$('a[href*="mailto:"]').on('click', function () {
217		basicEventAjax('Contact - Email');
218	});
219
220	// Newsletter - Submit Button event
221	$(document).on('click', '.sp-button', function() {
222		basicEventAjax('Newsletter - Submit Button');
223	});
224	
225	// Joia Specific Events
226	if ( $('body').hasClass('brand--joia')) {
227		// Check if on this page https://joiabattersea.co.uk/whats-on/joia-behind-the-pass-x-masaki-sugisaki/
228		if ( $('body').hasClass('postid-1104') ) {
229			$(document).on('click', '.button', function() {
230				// Get the href attribute value of the button
231				var href = $(this).attr('href');
232	
233				// Check if the href matches the desired value
234				if (href === 'https://www.opentable.co.uk/r/joia-restaurant-and-bar-london') {
235					basicEventAjax('JOIA - Behind The Pass Book Now Button');
236				}
237			});
238		}
239	}
240	
241	// Arca Specific Events
242	if ( $('body').hasClass('brand--arca')) {
243		// Formitable Events
244		window.addEventListener('ft-widget-open', function(e) {
245			basicEventAjax('Formitable - Open');
246		});
247		window.addEventListener('ft-widget-close', function(e) {
248			basicEventAjax('Formitable - Closed');
249		});
250		window.addEventListener('ft-widget-ordered', function(e) {
251			basicEventAjax('Formitable - Booked');
252	
253			purchaseEventAjax('ARCA - Booking Confirmed', event.detail);
254		});
255	}
256});

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.