PageSourceSearch

https://www.bouyguestelecom-pro.fr/static/version1791498041/fronte…/js/tag-commander-init.js

js bouyguestelecom-pro.fr collected 2026-10-09 04:53:47 UTC 3,484 bytes, 112 lines download raw bytes

1(function () {
2    'use strict';
3
4    function getMetaContent(name) {
5        var meta = document.querySelector('meta[name="' + name + '"]');
6
7        return meta ? meta.getAttribute('content') || '' : '';
8    }
9
10    function ensureHiddenInput(id, value) {
11        if (!value) {
12            return;
13        }
14
15        function appendInput() {
16            var existing = document.getElementById(id);
17            var input;
18
19            if (existing) {
20                existing.value = value;
21                return;
22            }
23
24            input = document.createElement('input');
25            input.type = 'hidden';
26            input.id = id;
27            input.value = value;
28            document.body.appendChild(input);
29        }
30
31        if (document.body) {
32            appendInput();
33            return;
34        }
35
36        document.addEventListener('DOMContentLoaded', appendInput, { once: true });
37    }
38
39    function buildTcVars() {
40        var productId = getMetaContent('bte:tc-product-id');
41        var productName = getMetaContent('bte:tc-product-name');
42        var productCategory = getMetaContent('bte:tc-product-category');
43        var productPrice = getMetaContent('bte:tc-product-price');
44        var tcVars = {
45            env_template: window.magePageType || getMetaContent('bte:page-type'),
46            env_work: window.env_work || '',
47            pagename: window.magePageName || getMetaContent('bte:page-name')
48        };
49
50        if (productId || productName || productCategory || productPrice) {
51            tcVars.id = productId;
52            tcVars.name = productName;
53            tcVars.category_name = productCategory;
54            tcVars.product_price = productPrice;
55        }
56
57        window.tc_vars = tcVars;
58
59        ensureHiddenInput('gtm_product_name', productName);
60        ensureHiddenInput('gtm_category_name', productCategory);
61        ensureHiddenInput('gtm_product_id', productId);
62
63        return {
64            productId: productId,
65            productName: productName,
66            productCategory: productCategory,
67            productPrice: productPrice
68        };
69    }
70
71    function triggerProductViewEvent(productData) {
72        if (!productData.productId && !productData.productName) {
73            return;
74        }
75
76        function sendEvent() {
77            if (typeof window.triggerTagCommanderEvent !== 'function' || typeof window.tC === 'undefined' || !window.tC.event) {
78                return false;
79            }
80
81            window.triggerTagCommanderEvent({
82                event_category: 'Vue page produit smartphone',
83                event_action: 'Page produit smartphone',
84                event_label: window.location.pathname,
85                category_name: productData.productCategory,
86                name: productData.productName,
87                product_price: productData.productPrice,
88                id: productData.productId
89            });
90
91            return true;
92        }
93
94        if (sendEvent()) {
95            return;
96        }
97
98        window.addEventListener('load', function () {
99            var attempts = 0;
100            var intervalId = window.setInterval(function () {
101                attempts += 1;
102                if (sendEvent() || attempts >= 20) {
103                    window.clearInterval(intervalId);
104                }
105            }, 250);
106        }, { once: true });
107    }
108
109    window.TagCommanderEnabled = getMetaContent('bte:tc-enabled');
110
111    triggerProductViewEvent(buildTcVars());
112})();

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.