PageSourceSearch

https://www.lesbullesdeparis.com/wp-content/plugins/fb-tracking/js/fb_tracking.js

js lesbullesdeparis.com collected 2026-09-28 10:45:55 UTC 11,087 bytes, 320 lines download raw bytes

1// Current tracking uses FB_useGoogleAnalytics for events
2// Hence, we want to override the value and set it to false in order to stop the current tracking
3var FB_useGoogleAnalytics_Promise = jQuery.Deferred(function (dfd) {
4	waitFB_useGoogleAnalytics = setInterval(function(){
5		if(typeof(FB_useGoogleAnalytics)!=='undefined') {
6			clearInterval(waitFB_useGoogleAnalytics);
7			dfd.resolve(FB_useGoogleAnalytics);
8		}
9	}, 1000);
10	setTimeout(function () {
11		dfd.reject(new Error('Error waiting fblib function'));
12	}, 5000);
13}).promise();
14
15FB_useGoogleAnalytics_Promise.then(function(resp){
16	if ( resp !== false ){
17		FB_useGoogleAnalytics = false;
18	}
19}).fail(function(error){
20	var FB_useGoogleAnalytics = false;
21	clearInterval(waitFB_useGoogleAnalytics);
22});
23
24var FB_useAsyncGoogleAnalytics_Promise = jQuery.Deferred(function (dfd) {
25	waitFB_useAsyncGoogleAnalytics = setInterval(function(){
26		if(typeof(FB_useAsyncGoogleAnalytics)!=='undefined') {
27			clearInterval(waitFB_useAsyncGoogleAnalytics);
28			dfd.resolve(FB_useAsyncGoogleAnalytics);
29		}
30	}, 1000);
31	setTimeout(function () {
32		dfd.reject(new Error('Error waiting fblib function'));
33	}, 5000);
34}).promise();
35
36FB_useGoogleAnalytics_Promise.then(function(resp){
37	if ( resp !== false ){
38		FB_useAsyncGoogleAnalytics = false;
39	}
40}).fail(function(error){
41	var FB_useAsyncGoogleAnalytics = false;
42	clearInterval(waitFB_useAsyncGoogleAnalytics);
43});
44
45// Old way of waiting for fblib vars
46// Replaced by a promise for new pro theme using a js loader
47// if (typeof FB_useGoogleAnalytics !== 'undefined'){
48// 	FB_useGoogleAnalytics = false;
49// }
50// else {
51// 	var FB_useGoogleAnalytics = false;
52// }
53// if (typeof FB_useAsyncGoogleAnalytics !== 'undefined'){
54// 	FB_useAsyncGoogleAnalytics = false;
55// }
56// else {
57// 	var FB_useAsyncGoogleAnalytics = false;
58// }
59
60( function( $ ){
61	function isGA4(tracker) {
62		return /^G-.+/.test(tracker);
63	}
64	if ( typeof fb_send_event === 'undefined'){
65		// Function to handle the tracking for one event
66		// selector : css selector
67		// type : menu (if more than one element to track) || button
68		// category, action and label are params we want to pass for the event
69		// interval : if the event we want to track is loaded after page load
70		function fb_send_event( selector, type, category, action, label, interval ){
71			// If the css selector element is loaded at page load
72			if ( interval === '' || interval === null ){
73				// If we want to track more than one element
74				if (type == 'menu'){
75					// For each element
76					$(selector).each( function( index ){
77						// Set the index of the element
78						// Ex: 4 offers, the first will be 1 etc...
79						var number = index + 1;
80						// Set the on click function
81						$(this).click(function(){
82							// If the params are set and we have the trackers
83							if (typeof fb_tracking_var !== 'undefined' && typeof fb_tracking_var.tracker !== 'undefined'){
84								// If we dont use gtm
85								if ( typeof fb_tracking_var.usegtm !== 'undefined' && fb_tracking_var.usegtm === '0' ) {
86									// For each tracker
87									$.each( fb_tracking_var.tracker, function( index, value){
88										if (isGA4(value)) {
89											gtag('event', action, {
90												send_to: value,
91												event_category: category,
92												event_label: label + '_' + number
93											});
94										} else {
95											// The 1st tracker in the gua api is named 'default'
96											if ( value === 'default'){
97												// We push the event in gua
98												// the label will be smth like offer_1
99												ga( 'send','event', category, action, label + '_' + number );
100											}
101											// If its not the 1st tracker
102											else {
103												// Push the event
104												ga( value + '.send','event', category, action, label + '_' + number);
105											}
106										}
107									});
108								}
109								// We Push only the variables and GTM handles the rest for each tags
110								else{
111
112									dataLayer.push({
113										event: 'Action trackings',
114										'category': category,
115										'action': action,
116										'label': label + '_' + number,
117										'interaction': false,
118									});
119
120								}
121							}
122						})
123					})
124				}
125				// If we want to track only one element
126				else if ( type == 'button'){
127					// Set the on click function
128					$( selector ).click(function() {
129						// If the params are set and we have the trackers
130						if (typeof fb_tracking_var != 'undefined' && typeof fb_tracking_var.tracker != 'undefined'){
131							
132							// If we dont use gtm
133							if ( typeof fb_tracking_var.usegtm !== 'undefined' && fb_tracking_var.usegtm === '0' ) {
134								// For each tracker
135								$.each( fb_tracking_var.tracker, function( index, value){
136									if (isGA4(value)) {
137										gtag('event', action, {
138											send_to: value,
139											event_category: category,
140											event_label: label
141										});
142									} else {
143										// The 1st tracker in the gua api is named 'default'
144										if ( value === 'default'){
145											// We push the event in gua
146											// the label will be smth like offer
147											ga( 'send','event', category, action, label );
148										}
149										// If its not the 1st tracker
150										else {
151											// Push the event
152											ga( value + '.send','event', category, action, label);
153										}
154									}
155								});
156							}
157							// We Push only the variables and GTM handles the rest for each tags
158							else {
159
160								dataLayer.push({
161									event: 'Action trackings',
162									'category': category,
163									'action': action,
164									'label': label,
165									'interaction': false,
166								});
167
168							}
169						}
170					});
171				}
172			}
173			else {
174				// If the css selector element is not loaded at page load but asynchronously with JS
175				// We set the on click on a parent element loaded at the page load that will bubble to the selector later on
176				$( interval ).on( 'click', selector, function(){
177					// If we want to track only one element
178					if ( type == 'button' ){
179						if (typeof fb_tracking_var != 'undefined' && typeof fb_tracking_var.tracker != 'undefined'){
180							if ( typeof fb_tracking_var.usegtm !== 'undefined' && fb_tracking_var.usegtm === '0' ) {
181								// For each tracker
182								$.each( fb_tracking_var.tracker, function( index, value){
183									if (isGA4(value)) {
184										gtag('event', action, {
185											send_to: value,
186											event_category: category,
187											event_label: label
188										});
189									} else {
190										if ( value === 'default'){
191											ga( 'send','event', category, action, label );
192										}
193										else {
194											ga( value + '.send','event', category, action, label);
195										}
196									}
197								});
198							}
199							else {
200
201								dataLayer.push({
202									event: 'Action trackings',
203									'category': category,
204									'action': action,
205									'label': label,
206									'interaction': false,
207								});
208
209							}
210						}
211					}
212					// If we want to track more than one element
213					else if ( type == 'menu' ){
214						if (typeof fb_tracking_var != 'undefined' && typeof fb_tracking_var.tracker != 'undefined'){
215							// Set the index for each element
216							current_selector_index = $(this).index(selector) + 1;
217							if ( typeof fb_tracking_var.usegtm !== 'undefined' && fb_tracking_var.usegtm === '0' ) {
218								// For each tracker
219								$.each( fb_tracking_var.tracker, function( index, value){
220									if (isGA4(value)) {
221										gtag('event', action, {
222											send_to: value,
223											event_category: category,
224											event_label: label + '_' + current_selector_index
225										});
226									} else {
227										if (value === 'default') {
228											ga('send', 'event', category, action, label + '_' + current_selector_index);
229										} else {
230											ga(value + '.send', 'event', category, action, label + '_' + current_selector_index);
231										}
232									}
233								});
234							}
235							else{
236
237								dataLayer.push({
238									event: 'Action trackings',
239									'category': category,
240									'action': action,
241									'label': label + '_' + current_selector_index,
242									'interaction': false,
243								});
244
245							}
246						}	
247					}
248				});
249			}
250		}
251	}
252
253	$(document).ready( function (){
254		// If we want to track events
255		if ( typeof fb_tracking_var !== 'undefined' && typeof fb_tracking_var.usetracking !== 'undefined' && fb_tracking_var.usetracking === '1' ){
256			// If there are events
257			if ( typeof fb_tracking_var.events !== 'undefined' ){
258				// For each events, use the fb_send_event to handle the tracking
259				$.each( fb_tracking_var.events, function( event_index, event_value ){			
260					fb_send_event( event_value.selector, event_value.type, event_value.category, event_value.action, event_value.label, event_value.interval );
261				});
262			}
263
264			// Social Connect Custom dimension Tracking
265			if ( typeof fb_tracking_var.socialconnect !== 'undefined' && fb_tracking_var.socialconnect == '1' && typeof fb_tracking_var.tracker != 'undefined' ){
266				var dimensionValue = 'Not Connected';
267				var co = '';
268				// If we don't use GTM
269				if ( typeof fb_tracking_var.usegtm !== 'undefined' && fb_tracking_var.usegtm === '0' ) {
270					//For each trackers
271					$.each( fb_tracking_var.tracker, function( index, value){
272						if ( value === 'default'){
273							// If connected, we change the value of the dimension
274							if( typeof localStorage.user_id !== 'undefined' ){
275								dimensionValue = 'Connected';
276								var co = localStorage.user_id;
277							  	ga('set', 'userId', localStorage.user_id);
278							  	ga('set', '&uid', localStorage.user_id); 
279							}
280
281							ga('set', 'dimension1', dimensionValue);
282							ga('send', 'event', 'Connexion Tracking', 'Page View', {
283							nonInteraction: true
284							});
285						}
286						else {
287							// If connected, we change the value of the dimension
288							if( typeof localStorage.user_id !== 'undefined' ){
289								dimensionValue = 'Connected';
290								var co = localStorage.user_id;
291							  	ga(value + '.set', 'userId', localStorage.user_id);
292							  	ga(value + '.set', '&uid', localStorage.user_id); 
293							}
294							ga(value + '.set', 'dimension1', dimensionValue);
295							ga(value + '.send', 'event', 'Connexion Tracking', 'Page View', {
296							nonInteraction: true
297							});
298						}
299					});
300				}
301				else{
302					// If connected, we change the vakue of the dimension
303					if( typeof localStorage.user_id !== 'undefined' ){
304						dimensionValue = 'Connected';
305						var co = localStorage.user_id;
306						dataLayer.push({
307						  	'user_id': localStorage.user_id,
308						});
309					}
310					dataLayer.push({
311						'interaction': true,
312					  	'connexion': dimensionValue,
313					  	event: 'Connexion Tracking',
314					  	'category': 'Page View',
315					});
316				}
317			}
318		}
319	});
320})(jQuery);

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.