PageSourceSearch

https://www.velozen.com/modules/facebookproductad/views/js/pixel.js

js velozen.com collected 2026-10-07 22:37:31 UTC 14,099 bytes, 303 lines download raw bytes

1/*
2*
3* Dynamic Ads + Pixel
4*
5* @author    BusinessTech.fr - https://www.businesstech.fr
6* @copyright Business Tech - https://www.businesstech.fr
7* @license   Commercial
8*
9*           ____    _______
10*          |  _ \  |__   __|
11*          | |_) |    | |
12*          |  _ <     | |
13*          | |_) |    | |
14*          |____/     |_|
15*
16*/
17
18$(document).ready(function () {
19
20    if (btPixel.pixel_id != "") {
21        // Init the pixel code
22        !(function (f, b, e, v, n, t, s) {
23            if (f.fbq) return;
24            n = f.fbq = function () {
25                n.callMethod ? n.callMethod.apply(n, arguments) : n.queue.push(arguments);
26            };
27            if (!f._fbq) f._fbq = n;
28            n.push = n;
29            n.loaded = !0;
30            n.version = "2.0";
31            n.queue = [];
32            t = b.createElement(e);
33            t.async = !0;
34            t.src = v;
35            s = b.getElementsByTagName(e)[0];
36            s.parentNode.insertBefore(t, s);
37        })(window, document, "script", "https://connect.facebook.net/en_US/fbevents.js");
38
39        fbq('set', 'autoConfig', false, btPixel.pixel_id);
40
41        if (btPixel.bUseConsent == true) {
42            if (btPixel.bConsentHtmlElement != "") {
43                $(btPixel.bConsentHtmlElement).bind("click", function (event) {
44                    $.ajax({
45                        type: "POST",
46                        url: btPixel.ajaxUrl,
47                        dataType: "json",
48                        data: {
49                            ajax: 1,
50                            action: "updateConsent",
51                            token: btPixel.token,
52                        },
53                        success: function (jsonData, textStatus, jqXHR) {
54                            fbq("init", btPixel.pixel_id);
55                            fbq("track", "PageView");
56                            fbq("consent", "grant");
57                        },
58                    });
59                });
60            }
61
62            // Use the consent level from ACB
63            if (btPixel.iConsentConsentLvl == 0) {
64                fbq("consent", "revoke");
65            } else if (btPixel.iConsentConsentLvl == 1) {
66                fbq("consent", "revoke");
67            } else if (btPixel.iConsentConsentLvl == 2) {
68                if (btPixel.advancedMatchingData == false || btPixel.useAdvancedMatching == false) {
69                    fbq("init", btPixel.pixel_id, {
70                        external_id: btPixel.external_id,
71                    });
72                } else {
73                    fbq("init", btPixel.pixel_id, {
74                        external_id: btPixel.external_id,
75                        em: btPixel.advancedMatchingData.em,
76                        fn: btPixel.advancedMatchingData.fn,
77                        ln: btPixel.advancedMatchingData.ln,
78                    });
79                }
80
81                fbq("track", "PageView");
82                fbq("consent", "grant");
83            } else if (btPixel.iConsentConsentLvl == 3) {
84                if (btPixel.advancedMatchingData == false || btPixel.useAdvancedMatching == false) {
85                    fbq("init", btPixel.pixel_id, {
86                        external_id: btPixel.external_id,
87                    });
88                } else {
89                    fbq("init", btPixel.pixel_id, {
90                        external_id: btPixel.external_id,
91                        em: btPixel.advancedMatchingData.em,
92                        fn: btPixel.advancedMatchingData.fn,
93                        ln: btPixel.advancedMatchingData.ln,
94                    });
95                }
96                fbq("track", "PageView");
97                fbq("consent", "grant");
98            }
99        } else {
100            if (btPixel.advancedMatchingData == false || btPixel.useAdvancedMatching == false) {
101                fbq("init", btPixel.pixel_id, {
102                    external_id: btPixel.external_id,
103                });
104            } else {
105                fbq("init", btPixel.pixel_id, {
106                    external_id: btPixel.external_id,
107                    em: btPixel.advancedMatchingData.em,
108                    fn: btPixel.advancedMatchingData.fn,
109                    ln: btPixel.advancedMatchingData.ln,
110                });
111            }
112
113            fbq("track", "PageView");
114            fbq("consent", "grant");
115        }
116
117        if (typeof btPixel.tagContent !== "undefined" && typeof btPixel.tagContent.aTrackingType !== "undefined" || typeof btPixel.tagContent.aDynTags.content_name !== "undefined" || typeof btPixel.tagContent.aDynTags.content_ids !== "undefined") {
118
119            if (btPixel.tagContent.aTrackingType.value == "ViewContent" && typeof btPixel.tagContent.aDynTags.content_name !== "undefined") {
120                fbq("track", "ViewContent", {
121                    content_name: btPixel.tagContent.aDynTags.content_name.value,
122                    content_category: btPixel.tagContent.aDynTags.content_category.value,
123                    content_ids: btPixel.tagContent.aDynTags.content_ids.value,
124                    content_type: btPixel.tagContent.aDynTags.content_type.value,
125                    value: btPixel.tagContent.aDynTags.value.value,
126                    currency: btPixel.tagContent.aDynTags.currency.value,
127                },
128                    { 'eventID': btPixel.eventId });
129            }
130
131            if (typeof btPixel.tagContent.aDynTags.content_ids !== "undefined") {
132                if (btPixel.tagContent.aTrackingType.value == "ViewCategory") {
133                    fbq("track", "ViewCategory", {
134                        content_name: btPixel.tagContent.aDynTags.content_name.value,
135                        content_category: btPixel.tagContent.aDynTags.content_category.value,
136                        content_ids: btPixel.tagContent.aDynTags.content_ids.value,
137                        content_type: btPixel.tagContent.aDynTags.content_type.value,
138                    },
139                        { 'eventID': btPixel.eventId });
140                }
141            } else {
142                if (btPixel.tagContent.aTrackingType.value == "ViewCategory") {
143                    if (typeof btPixel.tagContent.aDynTags.content_name !== "undefined") {
144                        fbq("track", "ViewCategory", {
145                            content_name: btPixel.tagContent.aDynTags.content_name.value,
146                            content_category: btPixel.tagContent.aDynTags.content_category.value,
147                            content_type: btPixel.tagContent.aDynTags.content_type.value,
148                        },
149                            { 'eventID': btPixel.eventId });
150                    }
151                }
152            }
153
154            if (btPixel.tagContent.aTrackingType.value == "ViewContentHomepage") {
155
156                if (typeof btPixel.tagContent.aDynTags.content_ids !== "undefined" && typeof btPixel.tagContent.aDynTags.content_ids.value !== "undefined") {
157                    fbq("track", "ViewContentHomepage", {
158                        content_name: btPixel.tagContent.aDynTags.content_name.value,
159                        content_category: btPixel.tagContent.aDynTags.content_category.value,
160                        content_ids: btPixel.tagContent.aDynTags.content_ids.value,
161                        content_type: btPixel.tagContent.aDynTags.content_type.value,
162                    },
163                        { 'eventID': btPixel.eventId });
164                } else {
165                    fbq("track", "ViewContentHomepage", {
166                        content_name: btPixel.tagContent.aDynTags.content_name.value,
167                        content_category: btPixel.tagContent.aDynTags.content_category.value,
168                        content_type: btPixel.tagContent.aDynTags.content_type.value,
169                    },
170                        { 'eventID': btPixel.eventId });
171                }
172            }
173
174            if (btPixel.tagContent.aTrackingType.value == "AddToCart") {
175                fbq("track", "AddToCart", {
176                    content_ids: btPixel.tagContent.aDynTags.content_ids.value,
177                    content_type: btPixel.tagContent.aDynTags.content_type.value,
178                    value: btPixel.tagContent.aDynTags.value.value,
179                    currency: btPixel.tagContent.aDynTags.currency.value,
180                },
181                    { 'eventID': btPixel.eventId });
182            }
183
184            // Handle Contact event
185            if (btPixel.tagContent.aTrackingType.value == "Contact") {
186                fbq("track", "Contact", {}, { 'eventID': btPixel.eventId });
187            }
188
189            if (btPixel.tagContent.aTrackingType.value == "Purchase") {
190                fbq("track", "Purchase", {
191                    content_ids: btPixel.tagContent.aDynTags.content_ids.value,
192                    content_type: btPixel.tagContent.aDynTags.content_type.value,
193                    value: btPixel.tagContent.aDynTags.value.value,
194                    currency: btPixel.tagContent.aDynTags.currency.value,
195                },
196                    { 'eventID': btPixel.eventId });
197            }
198
199            if (btPixel.tagContent.aTrackingType.value == "Search") {
200                fbq("track", "Search", {
201                    content_ids: btPixel.tagContent.aDynTags.content_ids.value,
202                    content_type: btPixel.tagContent.aDynTags.content_type.value,
203                    query: btPixel.tagContent.aDynTags.search_string.value,
204                },
205                    { 'eventID': btPixel.eventId });
206            }
207            $(btPixel.btnAddToWishlist).bind("click", function () {
208                fbq("track", "AddToWishlist", {
209                    content_ids: btPixel.tagContent.aDynTags.content_ids.value,
210                    content_type: btPixel.tagContent.aDynTags.content_type.value,
211                    value: btPixel.tagContent.aDynTags.value.value,
212                    currency: btPixel.tagContent.aDynTags.currency.value,
213                },
214                    { 'eventID': btPixel.eventId });
215            });
216
217            $(btPixel.btnSub).bind("click", function () {
218                fbq("track", "Subscribe", {
219                    content_name: btPixel.tagContent.content_name.value,
220                    content_category: btPixel.tagContent.content_category.value,
221                    content_ids: btPixel.tagContent.content_ids.value,
222                    content_type: btPixel.tagContent.content_type.value,
223                    value: btPixel.tagContent.value.value,
224                    currency: btPixel.tagContent.currency.value,
225                },
226                    { 'eventID': btPixel.eventId });
227            });
228
229            $('.ps-shown-by-js').each(function (index) {
230                $(this).bind("click", function (event) {
231                    fbq("track", "AddPaymentInfo", {}, { 'eventID': btPixel.eventId });
232                })
233            });
234
235            if (btPixel.tagContent.aTrackingType.value == "InitiateCheckout") {
236                fbq("track", "InitiateCheckout", { 'eventID': btPixel.eventId });
237            }
238        }
239
240
241        if (typeof prestashop !== 'undefined') {
242            prestashop.on(
243                'updateCart',
244                function (event) {
245                    if (typeof event.resp !== "undefined") {
246                        let current_content;
247                        if (btPixel.comboExport == 0) {
248                            current_content = btPixel.prefix +  btPixel.prefixLang + event.resp.id_product;
249                        } else {
250                            if (event.resp.id_product_attribute != "0") {
251                                current_content = btPixel.prefix +  btPixel.prefixLang + event.resp.id_product + btPixel.fbdaSeparator + event.resp.id_product_attribute;
252                            } else {
253                                current_content = btPixel.prefix +  btPixel.prefixLang + event.resp.id_product;
254                            }
255                        }
256
257                        if (event && event.reason && event.reason.linkAction == "add-to-cart") {
258                            fbq("track", "AddToCart", {
259                                content_ids: current_content,
260                                content_type: 'product',
261                                value: event.resp.cart.totals.total.amount,
262                                currency: btPixel.pixelCurrency,
263                            },
264                                { 'eventID': btPixel.eventId });
265                        }
266                    }
267                }
268            );
269
270            // Handle case for combination update
271            prestashop.on(
272                'updatedProduct',
273                function (event) {
274                    if (event) {
275                        $.ajax({
276                            type: "POST",
277                            url: btPixel.ajaxUrl,
278                            dataType: "json",
279                            data: {
280                                ajax: 1,
281                                action: "updateCombination",
282                                id_product_attribute: event.id_product_attribute,
283                                id_product: $('input[name="id_product"').val(),
284                                token: btPixel.token,
285                            },
286                            success: function (jsonData, textStatus, jqXHR) {
287                                fbq('set', 'autoConfig', false, btPixel.pixel_id);
288                                fbq("track", "ViewContent", {
289                                    content_name: jsonData.content_name,
290                                    content_category: jsonData.content_category,
291                                    content_ids: jsonData.content_id,
292                                    content_type: 'product',
293                                    value: jsonData.value,
294                                    currency: jsonData.currency,
295                                });
296                            },
297                        });
298                    }
299                }
300            );
301        }
302    }
303});

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.