/* Minification failed. Returning unminified contents.
(152,99-100): run-time error JS1195: Expected expression: >
(164,18-19): run-time error JS1195: Expected expression: )
(165,14-15): run-time error JS1100: Expected ',': ;
(171,9-10): run-time error JS1002: Syntax error: }
(172,36-37): run-time error JS1004: Expected ';': {
(179,90-91): run-time error JS1195: Expected expression: >
(191,18-19): run-time error JS1195: Expected expression: )
(198,9-10): run-time error JS1002: Syntax error: }
(217,29-30): run-time error JS1010: Expected identifier: (
(228,10-11): run-time error JS1195: Expected expression: ,
(254,69-70): run-time error JS1004: Expected ';': {
(286,60-61): run-time error JS1195: Expected expression: >
(288,58-59): run-time error JS1195: Expected expression: >
(288,111-112): run-time error JS1004: Expected ';': )
(289,18-19): run-time error JS1195: Expected expression: ,
(290,33-34): run-time error JS1004: Expected ';': {
(291,18-19): run-time error JS1195: Expected expression: )
(292,50-51): run-time error JS1004: Expected ';': {
(303,9-10): run-time error JS1002: Syntax error: }
(304,49-50): run-time error JS1004: Expected ';': {
(321,10-11): run-time error JS1195: Expected expression: ,
(322,54-55): run-time error JS1004: Expected ';': {
(338,10-11): run-time error JS1195: Expected expression: ,
(339,34-35): run-time error JS1195: Expected expression: )
(339,36-37): run-time error JS1004: Expected ';': {
(351,10-11): run-time error JS1195: Expected expression: ,
(352,35-36): run-time error JS1195: Expected expression: )
(352,37-38): run-time error JS1004: Expected ';': {
(364,10-11): run-time error JS1195: Expected expression: ,
(365,56-57): run-time error JS1004: Expected ';': {
(378,10-11): run-time error JS1195: Expected expression: ,
(379,54-55): run-time error JS1004: Expected ';': {
(392,10-11): run-time error JS1195: Expected expression: ,
(393,19-20): run-time error JS1197: Too many errors. The file might not be a JavaScript file: :
(197,13-27): run-time error JS1018: 'return' statement outside of function: return orderDL
(190,21-37): run-time error JS1018: 'return' statement outside of function: return elementDL
(170,13-26): run-time error JS1018: 'return' statement outside of function: return cartDL
 */
var SkywalkerTracciamentoGTM = {
    Data: {
        Esposizione: {
            searchId: null,
            searchName: null,
            keyword: null
        },
        Cache: {
            Categorie: {}
        }
    },
    Settings: {
        NomeAffiliato: "GTM",
        AffiliationInformations: null,
        InitializeAffiliation: function () {
            //Imposta informazioni affiliato
            if (!SkywalkerTracciamentoGTM.Settings.AffiliationInformations) {
                SkywalkerTracciamentoGTM.Services.AffiliationInformations(
                    function (data) {
                        SkywalkerTracciamentoGTM.Settings.AffiliationInformations = data
                    },
                    function (data) {
                    });
            }
        },
        Environment: {}
    },
    Services: {
        UserOrderStatistics: function (callback, failed) {
            jQuery.ajax({
                type: "POST",
                async: false,
                url: "/svc/ServizioInformazioniOrdini.svc/Personale/OttieniStatisticheOrdiniUtenteCorrente",
                dataType: "json",
                contentType: "application/json",
                processData: true
            })
                .done(function (data) {
                    if (data.Success) {
                        callback(data.Value);
                    } else {
                        failed(data);
                    }
                });
        },
        AffiliationInformations: function (callback, failed) {
            jQuery.ajax({
                type: "GET",
                async: false,
                url: "/svc/ServizioInformazioniTracciamento.svc/Tracciamento/OttieniInformazioniAffiliato?codiceAffiliato=" + SkywalkerTracciamentoGTM.Settings.NomeAffiliato,
                dataType: "json",
                contentType: "application/json",
                processData: true
            })
                .done(function (data) {
                    if (data.Success) {
                        callback(data.Value);
                    } else {
                        failed(data);
                    }
                });
        }
    },
    Utils: {
        Round2: function (number) {
            return Math.round(number * 100) / 100;
        }
    },
    Mapper: {
        MapUser: function (user) {
            var userDL = null;
            if (!user.Anonimo) {
                userDL = {
                    'user_id': user.CodiceUtente.toString()
                };
            };
            return userDL;
        },
        //NOT SUPPORTED IN GA4
        /*
        MapCategory: function (category) {
            var categoryDL = {
                'id': category.CodiceCategoria,
                'name': category.NomeCategoria,
                'level': category.LivelloCategoria
            };
            return categoryDL;
        },
        */
        //NOT SUPPORTED IN GA4
        /*
        MapBrand: function (brand) {
            var brandDL = {
                'id': brand.CodiceMarchio,
                'name': brand.NomeMarchio
            };
            return brandDL;
        },
        */
        MapBreadcrumb: function (categoryId, elementDL) {
            var breadcrumbData;
            if (!SkywalkerTracciamentoGTM.Data.Cache.Categorie[categoryId]) {
                SkywalkerTracciamento.Services.InformazioniPercorsoCategoria(categoryId,
                    function (data) {
                        breadcrumbData = data;
                    },
                    function (data) {
                    });
                SkywalkerTracciamentoGTM.Data.Cache.Categorie[categoryId] = breadcrumbData;
            } else {
                breadcrumbData = SkywalkerTracciamentoGTM.Data.Cache.Categorie[categoryId]
            }
            if (breadcrumbData && breadcrumbData[0]) {
                elementDL['item_category'] = breadcrumbData[0].NomeCategoria;
            }
            if (breadcrumbData && breadcrumbData[1]) {
                elementDL['item_category2'] = breadcrumbData[1].NomeCategoria;
            }
            if (breadcrumbData && breadcrumbData[2]) {
                elementDL['item_category3'] = breadcrumbData[2].NomeCategoria;
            }
            if (breadcrumbData && breadcrumbData[3]) {
                elementDL['item_category4'] = breadcrumbData[3].NomeCategoria;
            }
            if (breadcrumbData && breadcrumbData[4]) {
                elementDL['item_category5'] = breadcrumbData[4].NomeCategoria;
            }
            return elementDL;
        },
        MapProduct: function (product) {
            var productDL = {
                'item_id': product.Codice, // (M) (ex. "12345")
                'item_name': product.Descrizione.Breve, // (M) (ex. "iphone6")
                'item_brand': product.Marchio, // (ex. "apple")
                'discount': SkywalkerTracciamentoGTM.Utils.Round2(product.Prezzi.Sconto.Valore),
                'price': SkywalkerTracciamentoGTM.Utils.Round2(product.Prezzi.Prezzo.Valore), // (M) all tax included (ex. "590.50") Prezzo
                'currency': product.Prezzi.Prezzo.Valuta
            };
            productDL = SkywalkerTracciamentoGTM.Mapper.MapBreadcrumb(product.CodiceCategoria, productDL);
            if (SkywalkerTracciamentoGTM.Data.Esposizione.searchId) {
                productDL["item_list_id"] = SkywalkerTracciamentoGTM.Data.Esposizione.searchId;
            }
            if (SkywalkerTracciamentoGTM.Data.Esposizione.searchName) {
                productDL["item_list_name"] = SkywalkerTracciamentoGTM.Data.Esposizione.searchName;
            }
            return productDL;
        },
        MapCart: function (cart) {
            var cartDL = {
                'currency': cart.TotaleCarrello.ValoreTotale.Valuta, // Currency code (ISO code 4217)
                'value': SkywalkerTracciamentoGTM.Utils.Round2(cart.TotaleCarrello.ValoreTotale.Valore), // Order amount ATI (all tax included) with shipping fee                
                'items': (cart.ElementiCarrellabili) ? cart.ElementiCarrellabili.map(cartElement => {
                    var elementDL = {
                        'item_id': cartElement.Prodotto.Codice, // Product ID (= product ID mentionned in the product flows)                    
                        'item_name': cartElement.Prodotto.Descrizione.Breve, // Product name
                        'item_brand': cartElement.Prodotto.Marchio,
                        'discount': SkywalkerTracciamentoGTM.Utils.Round2(cartElement.Prodotto.Prezzi.Sconto.Valore),
                        'price': SkywalkerTracciamentoGTM.Utils.Round2(cartElement.Prodotto.Prezzi.Prezzo.Valore), // (M) all tax included (ex. "590.50") Prezzo
                        'currency': cartElement.Prodotto.Prezzi.Prezzo.Valuta,
                        'quantity': cartElement.Quantita
                    };
                    elementDL = SkywalkerTracciamentoGTM.Mapper.MapBreadcrumb(cartElement.Prodotto.CodiceCategoria, elementDL);
                    return elementDL;
                }) : []
            };
            var sconto = $(cart.Sconti).last()[0];
            if (sconto && sconto.Codice) {
                cartDL['coupon'] = sconto.Codice;
            }
            return cartDL;
        },
        MapOrder: function (order) {
            var orderDL = {
                'transaction_id': order.CodiceOrdine.toString(),
                'currency': order.TotaleOrdine.ValoreTotale.Valuta, // Currency code (ISO code 4217)
                'value': SkywalkerTracciamentoGTM.Utils.Round2(order.TotaleOrdine.ValoreTotale.Valore), // Order amount ATI (all tax included) with shipping fee                
                'tax': SkywalkerTracciamentoGTM.Utils.Round2((order.TotaleOrdine.ValoreTotaleProdotti.Valore - order.TotaleOrdine.ValoreTotaleProdottiNetto.Valore) + order.TotaleOrdine.ValoreTotaleSpese.Valore), // > 0 ? (totaleSpese - data.ModalitaConsegna.SpesaConsegna.Valore).toFixed(2) : "0.00"; // Taxes (charges - sf)
                'shipping': SkywalkerTracciamentoGTM.Utils.Round2(order.ModalitaConsegna.SpesaConsegna.Valore), // Order shipping fee ATI (all tax included) 
                'items': (order.DettagliOrdine) ? order.DettagliOrdine.map(orderElement => {
                    var elementDL = {
                        'item_id': orderElement.Prodotto.Codice, // Product ID (= product ID mentionned in the product flows)                    
                        'item_name': orderElement.Prodotto.Descrizione.Breve, // Product name
                        'item_brand': orderElement.Prodotto.Marchio,
                        'discount': SkywalkerTracciamentoGTM.Utils.Round2(orderElement.Prodotto.Prezzi.Sconto.Valore),
                        'price': SkywalkerTracciamentoGTM.Utils.Round2(orderElement.Prodotto.Prezzi.Prezzo.Valore), // (M) all tax included (ex. "590.50") Prezzo
                        'currency': orderElement.Prodotto.Prezzi.Prezzo.Valuta,
                        'quantity': orderElement.Quantita
                    };
                    elementDL = SkywalkerTracciamentoGTM.Mapper.MapBreadcrumb(orderElement.Prodotto.CodiceCategoria, elementDL);
                    return elementDL;
                }) : []
            };
            var sconto = $(order.Sconti).last()[0];
            if (sconto && sconto.Codice) {
                orderDL['coupon'] = sconto.Codice;
            }
            return orderDL;
        }
    },
    Trace: {
        //NOT SUPPORTED BY GA4
        /*
        TrackEnvironment: function (isMobileBrowser) {
            //Ottiene informazioni istanza
            SkywalkerTracciamento.Settings.InizializzaInformazioniContesto(
                function (data) {
                    window.dataLayer.push({
                        'language': data.LinguaCorrente.Codice,
                        'country': data.NazioneCorrente.Codice,
                        'instance': data.IstanzaCorrente.Codice
                    });
                },
                function (data) {
                });
        },
        */
        TrackUser: function () {
            // Ottiene informazioni utente autenticato
            SkywalkerTracciamento.Settings.InizializzaInformazioniUtente(
                function (userData) {
                    var user = SkywalkerTracciamentoGTM.Mapper.MapUser(userData);
                    if (user) {
                        window.dataLayer.push(user);
                    }
                },
                function (data) {
                });
        },
        //NOT SUPPORTED BY GA4
        /*
        TrackBrand: function (informazioniMarchio) {            
            if (informazioniMarchio) {
                var brand = SkywalkerTracciamentoGTM.Mapper.MapBrand(informazioniMarchio);
                window.dataLayer.push({                    
                    'brands': [ brand ]
                });
            }            
        },
        */
        //NOT SUPPORTED BY GA4
        /*
        TrackCategory: function (codiceCategoria) {            
            SkywalkerTracciamento.Settings.InizializzaInformazioniPercorsoCategoria(codiceCategoria,
                function (data) {                    
                    window.dataLayer.push({                        
                        'categories': data.map(category => SkywalkerTracciamentoGTM.Mapper.MapCategory(category))
                        
                    });
                },
                function (data) {
                });            
        },
        */
        TrackInternalSearchPage: function (informazioniEsposizione) {
            $.each(informazioniEsposizione.Filtri, function (k, filtro) {
                if (k == 0) { //solo primo filtro
                    switch (filtro.Nome) {
                        case "RICERCA":
                            SkywalkerTracciamentoGTM.Data.Esposizione.keyword = filtro.Valore;
                            SkywalkerTracciamentoGTM.Data.Esposizione.searchId = "ricerca";
                            SkywalkerTracciamentoGTM.Data.Esposizione.searchName = "Ricerca libera";
                            break;
                        case "CAT":
                            SkywalkerTracciamentoGTM.Data.Esposizione.searchId = "category_" + filtro.Valore;
                            SkywalkerTracciamentoGTM.Data.Esposizione.searchName = "Categoria " + filtro.Valore;
                            break;
                        case "ATTR":
                            SkywalkerTracciamentoGTM.Data.Esposizione.searchId = "attribute_" + filtro.Valore;
                            SkywalkerTracciamentoGTM.Data.Esposizione.searchName = "Attributo " + filtro.Valore;
                            break;
                        case "MAR":
                            SkywalkerTracciamentoGTM.Data.Esposizione.searchId = "brand_" + filtro.Valore;
                            SkywalkerTracciamentoGTM.Data.Esposizione.searchName = "Marchio " + filtro.Valore;
                            break;
                    }
                }
            });
            if (SkywalkerTracciamentoGTM.Data.Esposizione.keyword) {
                dataLayer.push({
                    'event': 'search',
                    'search_term': SkywalkerTracciamentoGTM.Data.Esposizione.keyword
                });
            }
            var products = new Array(); // (M)
            SkywalkerTracciamento.Services.InformazioniProdotti(
                informazioniEsposizione.Prodotti.map(prod => prod.Codice),
                function (productsData) {
                    products = productsData.map(product => SkywalkerTracciamentoGTM.Mapper.MapProduct(product));
                },
                function (data) {
                });
            if (products && products.length > 0) {
                dataLayer.push({ 'ecommerce': null });  // Clear the previous ecommerce object.
                dataLayer.push({
                    'event': 'view_item_list',
                    'ecommerce': {
                        'item_list_id': SkywalkerTracciamentoGTM.Data.Esposizione.searchId,
                        'item_list_name': SkywalkerTracciamentoGTM.Data.Esposizione.searchName,
                        'items': products
                    }
                });
            }
        },
        TrackProduct: function (codiceProdotto) {
            //SkywalkerTracciamento.Settings.InizializzaInformazioniProdotto(codiceProdotto,
            SkywalkerTracciamento.Services.InformazioniProdotto(codiceProdotto, //Passa direttamente dal servizio per evitare la "cache" dei Settings
                function (productData) {
                    var product = SkywalkerTracciamentoGTM.Mapper.MapProduct(productData)
                    product['quantity'] = 1;
                    dataLayer.push({ 'ecommerce': null });
                    dataLayer.push({
                        'event': 'view_item',
                        'ecommerce': {
                            'items': [product]
                        }
                    });

                },
                function (data) {
                });
        },
        TrackProductClick: function (codiceProdotto) {
            SkywalkerTracciamento.Settings.InizializzaInformazioniProdotto(codiceProdotto,
                function (productData) {
                    var product = SkywalkerTracciamentoGTM.Mapper.MapProduct(productData)
                    product['quantity'] = 1;
                    dataLayer.push({ 'ecommerce': null });
                    dataLayer.push({
                        'event': 'select_item',
                        'ecommerce': {
                            'items': [product]
                        }
                    });

                },
                function (data) {
                });
        },
        TrackViewCart: function () {
            SkywalkerTracciamento.Settings.InizializzaInformazioniCarrello(
                function (cartData) {
                    var cart = SkywalkerTracciamentoGTM.Mapper.MapCart(cartData);
                    dataLayer.push({ 'ecommerce': null });
                    dataLayer.push({
                        'event': 'view_cart',
                        'ecommerce': cart
                    });
                },
                function (data) {
                });
        },
        TrackBeginCart: function () {
            SkywalkerTracciamento.Settings.InizializzaInformazioniCarrello(
                function (cartData) {
                    var cart = SkywalkerTracciamentoGTM.Mapper.MapCart(cartData);
                    dataLayer.push({ 'ecommerce': null });
                    dataLayer.push({
                        'event': 'begin_checkout',
                        'ecommerce': cart
                    });
                },
                function (data) {
                });
        },
        TrackShippingMethod: function (shippingMethod) {
            SkywalkerTracciamento.Settings.InizializzaInformazioniCarrello(
                function (cartData) {
                    var cart = SkywalkerTracciamentoGTM.Mapper.MapCart(cartData);
                    cart['shipping_tier'] = shippingMethod;
                    dataLayer.push({ 'ecommerce': null });
                    dataLayer.push({
                        'event': 'add_shipping_info',
                        'ecommerce': cart
                    });
                },
                function (data) {
                });
        },
        TrackPaymentMethod: function (paymentMethod) {
            SkywalkerTracciamento.Settings.InizializzaInformazioniCarrello(
                function (cartData) {
                    var cart = SkywalkerTracciamentoGTM.Mapper.MapCart(cartData);
                    cart['payment_type'] = paymentMethod;
                    dataLayer.push({ 'ecommerce': null });
                    dataLayer.push({
                        'event': 'add_payment_info',
                        'ecommerce': cart
                    });
                },
                function (data) {
                });
        },
        TrackOrder: function (codiceOrdine) {
            SkywalkerTracciamento.Settings.InizializzaInformazioniOrdine(
                codiceOrdine,
                function (data) {
                    var order = SkywalkerTracciamentoGTM.Mapper.MapOrder(data);
                    dataLayer.push({ 'ecommerce': null });  // Clear the previous ecommerce object.
                    dataLayer.push({
                        'event': 'purchase',
                        'ecommerce': order
                    });
                },
                function (data) {
                });
        },
        TrackCrossSell: function (prodottoRiferimento, informazioniProdotti) {
            //NOT SUPPORTED BY GA4
            /*
            var crossSellProducts = new Array(); // (M)
            $.each(informazioniProdotti.Prodotti, function (k, prodotto) {   //.slice(0, 3), function (k, prodotto) {
                // Products List variables. Informations about the 3 first products present on the list/result page (JavaScript Array)                
                SkywalkerTracciamento.Services.InformazioniProdotto(prodotto.Codice,
                    function (productData) {
                        var product = SkywalkerTracciamentoGTM.Mapper.MapProduct(productData)     
                        crossSellProducts.push(product);
                    },
                    function (data) {
                    });
            });            
            var linkedProduct;
            SkywalkerTracciamento.Services.InformazioniProdotto(prodottoRiferimento,
                function (productData) {
                    linkedProduct = SkywalkerTracciamentoGTM.Mapper.MapProduct(productData,)                    
                },
                function (data) {
            });
            window.dataLayer.push({
                'crosssell_products' : products,
                'linked_product' : linkedProduct
            });
            */
        },
        TrackAddToCart: function (codiceProdotto, quantita) {
            SkywalkerTracciamentoGTM.Settings.InitializeAffiliation();
            SkywalkerTracciamento.Services.InformazioniProdotto(codiceProdotto,
                function (data) {
                    var product = SkywalkerTracciamentoGTM.Mapper.MapProduct(data);
                    if (quantita) {
                        product['quantity'] = quantita;
                    }
                    window.dataLayer.push({ 'ecommerce': null });
                    window.dataLayer.push({
                        'event': 'add_to_cart',
                        'ecommerce': {
                            'items': [product]
                        }
                    });
                },
                function (data) {
                });
        },
        TrackUpdateInCart: function (codiceProdotto, quantita, quantitaOld, codiciProdottiCollegati) {
            if (quantita != quantitaOld) {
                var eventName = (quantita > quantitaOld) ? 'add_to_cart' : 'remove_from_cart';
                var eventQuantity = (quantita > quantitaOld) ? (quantita - quantitaOld) : (quantitaOld - quantita);
                SkywalkerTracciamentoGTM.Settings.InitializeAffiliation();
                SkywalkerTracciamento.Services.InformazioniProdotto(codiceProdotto,
                    function (data) {
                        var products = new Array();
                        var product = SkywalkerTracciamentoGTM.Mapper.MapProduct(data);
                        product['quantity'] = eventQuantity;
                        products.push(product);
                        $.each(codiciProdottiCollegati, function (k, codiceProdottoCollegato) {
                            SkywalkerTracciamento.Services.InformazioniProdotto(codiceProdottoCollegato,
                                function (data) {
                                    var linkedProduct = SkywalkerTracciamentoGTM.Mapper.MapProduct(data);
                                    linkedProduct['quantity'] = eventQuantity;
                                    products.push(linkedProduct);
                                },
                                function (data) {
                                });
                        });
                        window.dataLayer.push({ 'ecommerce': null });
                        window.dataLayer.push({
                            'event': eventName,
                            'ecommerce': {
                                'items': products
                            }
                        });
                    },
                    function (data) {
                    }
                );
            }
        },
        TrackRemoveFromCart: function (codiceProdotto, codiciProdottiCollegati) {
            SkywalkerTracciamentoGTM.Settings.InitializeAffiliation();
            SkywalkerTracciamento.Services.InformazioniProdotto(codiceProdotto,
                function (data) {
                    var products = new Array();
                    products.push(SkywalkerTracciamentoGTM.Mapper.MapProduct(data));
                    $.each(codiciProdottiCollegati, function (k, codiceProdottoCollegato) {
                        SkywalkerTracciamento.Services.InformazioniProdotto(codiceProdottoCollegato,
                            function (data) {
                                products.push(SkywalkerTracciamentoGTM.Mapper.MapProduct(data));
                            },
                            function (data) {
                            });
                    });
                    window.dataLayer.push({ 'ecommerce': null });
                    window.dataLayer.push({
                        'event': 'remove_from_cart',
                        'ecommerce': {
                            'items': products
                        }
                    });
                },
                function (data) {
                });
        },
        TrackAddToWishlist: function (codiceProdotto) {
            SkywalkerTracciamentoGTM.Settings.InitializeAffiliation();
            SkywalkerTracciamento.Services.InformazioniProdotto(codiceProdotto,
                function (data) {
                    var product = SkywalkerTracciamentoGTM.Mapper.MapProduct(data);
                    window.dataLayer.push({ 'ecommerce': null });
                    window.dataLayer.push({
                        'event': 'add_to_wishlist',
                        'ecommerce': {
                            'items': [product]
                        }
                    });
                },
                function (data) {
                }
            );
        },
        TrackLogin: function () {
            SkywalkerTracciamentoGTM.Settings.InitializeAffiliation();
            window.dataLayer.push({
                'event': 'login'
            });
        },
        TrackRegisterAccount: function () {
            SkywalkerTracciamentoGTM.Settings.InitializeAffiliation();
            window.dataLayer.push({
                'event': 'sign_up'
            });
        },
        TrackRegisterNewsletter: function (email) {

        }
    }
};

// (M): mandatory

window.dataLayer = window.dataLayer || []; //Init GTM datalayer
SkywalkerTracciamentoGTM.Settings.InitializeAffiliation();
if (SkywalkerTracciamentoGTM.Settings.AffiliationInformations != null) {

    // ------------------------------------------------PAGINE ------------------------------------------

    //NOT SUPPORTED IN GA4
    /*
    $(document).on("CrossSell", function (event, pageName, isMobileBrowser, prodottoRiferimento, informazioniProdotti) {        
        if (informazioniProdotti && informazioniProdotti.Prodotti.length > 0) {            
            SkywalkerTracciamentoGTM.Trace.TrackCossSell(prodottoRiferimento, informazioniProdotti);            
        }        
    });
    */

    $(document).on("Global", function (event, isMobileBrowser) {
        SkywalkerTracciamentoGTM.Trace.TrackUser();
    });

    $(document).on("GenericEvent", function (event, eventName) {
        window.dataLayer.push({
            'event': eventName
        });
    });

    $(document).on("Page", function (event, pageName, isMobileBrowser) {

    });

    // NOT SUPPORTED IN GA4
    /*
    $(document).on("BrandPage", function (event, pageName, isMobileBrowser, informazioniMarchio) {        
        if (informazioniMarchio) {
            SkywalkerTracciamentoGTM.Trace.TrackBrand(informazioniMarchio);
        }        
    });
    */

    // NOT SUPPORTED IN GA4
    /*
    $(document).on("CategoryPage", function (event, pageName, isMobileBrowser, codiceCategoria) {
        
        if (codiceCategoria && codiceCategoria != "") {
            SkywalkerTracciamentoGTM.Trace.TrackCategory(codiceCategoria);
        }        
    });  
    */

    $(document).on("InternalSearchPage", function (event, pageName, isMobileBrowser, informazioniEsposizione) {
        if (informazioniEsposizione) {
            SkywalkerTracciamentoGTM.Trace.TrackInternalSearchPage(informazioniEsposizione);
        }
    });

    //$(document).on("ProductPage", function (event, pageName, isMobileBrowser, codiceProdotto) {
    //    if (codiceProdotto && codiceProdotto != "") {
    //        SkywalkerTracciamentoGTM.Trace.TrackProduct(codiceProdotto);
    //    }
    //});

    //$(document).on("CartPage", function (event, pageName, isMobileBrowser) {
    //    if (pageName && pageName.toLowerCase() === "carrello".toLowerCase()) {
    //        SkywalkerTracciamentoGTM.Trace.TrackViewCart();
    //    }
    //    if (pageName && pageName.toLowerCase() === "checkout".toLowerCase()) {
    //        SkywalkerTracciamentoGTM.Trace.TrackBeginCart();
    //    }
    //});

    //$(document).on("SelectShippingMethod", function (event, pageName, shippingMethod) {
    //    if (shippingMethod && shippingMethod != '')
    //        SkywalkerTracciamentoGTM.Trace.TrackShippingMethod(shippingMethod);
    //});

    //$(document).on("SelectPaymentMethod", function (event, pageName, paymentMethod) {
    //    if (paymentMethod && paymentMethod != '')
    //        SkywalkerTracciamentoGTM.Trace.TrackPaymentMethod(paymentMethod);
    //});

    //$(document).on("ConfirmationOrderPage", function (event, pageName, isMobileBrowser, codiceOrdine) {
    //    if (codiceOrdine && codiceOrdine != '' && pageName == 'ConfermaOrdine') {
    //        SkywalkerTracciamentoGTM.Trace.TrackOrder(codiceOrdine);
    //    }
    //});

    $(document).on("RegistrationPage", function (event, pageName, isMobileBrowser) {

    });

    $(document).on("RegistrationConfirmationPage", function (event, pageName, isMobileBrowser) {
        SkywalkerTracciamentoGTM.Trace.TrackRegisterAccount();
    });

    $(document).on("LoginConfirmationPage", function (event, pageName, isMobileBrowser) {
        SkywalkerTracciamentoGTM.Trace.TrackLogin();
    });
    $(document).on("ClubPage", function (event, pageName, isMobileBrowser) {

    });
    $(document).on("NewsletterRegistrationPage", function (event, pageName, isMobileBrowser) {

    });
    $(document).on("NewsletterConfirmationPage", function (event, pageName, email, isMobileBrowser) {
        SkywalkerTracciamentoGTM.Trace.TrackRegisterNewsletter(email);
    });
    $(document).on("NewsletterCancellationPage", function (event, pageName, email, isMobileBrowser) {

    });
    // ------------------------------------------------PAGINE ------------------------------------------

    // ------------------------------------------------EVENTI ------------------------------------------        
    //$(document).on("ViewProductDetails", function (event, eventName, codiceProdotto, link) {
    //    if (codiceProdotto && codiceProdotto != "") {
    //        SkywalkerTracciamentoGTM.Trace.TrackProductClick(codiceProdotto);
    //    }
    //});

    //$(document).on("AddToCartFromSearch", function (event, eventName, codiceProdotto, link) {
    //    if (codiceProdotto && codiceProdotto != "") {
    //        SkywalkerTracciamentoGTM.Trace.TrackAddToCart(codiceProdotto);
    //    }
    //});

    //$(document).on("AddToCartFromProduct", function (event, eventName, codiceProdotto, quantita) {
    //    if (codiceProdotto && codiceProdotto != "") {
    //        SkywalkerTracciamentoGTM.Trace.TrackAddToCart(codiceProdotto, quantita);
    //    }
    //});

    //$(document).on("DeleteProduct", function (event, eventName, codiceProdotto, codiciProdottiCollegati) {
    //    if (codiceProdotto && codiceProdotto != "") {
    //        SkywalkerTracciamentoGTM.Trace.TrackRemoveFromCart(codiceProdotto, codiciProdottiCollegati);
    //    }
    //});

    //$(document).on("UpdateProductQuantity", function (event, eventName, quantita, quantitaOld, codiceProdotto, codiciProdottiCollegati) {
    //    if (codiceProdotto && codiceProdotto != "" && quantita != quantitaOld) {
    //        SkywalkerTracciamentoGTM.Trace.TrackUpdateInCart(codiceProdotto, quantita, quantitaOld, codiciProdottiCollegati);
    //    }
    //});

    //$(document).on("AddToCartFromCrossSell", function (event, eventName, codiceProdotto, quantita) {
    //    if (codiceProdotto && codiceProdotto != "") {
    //        SkywalkerTracciamentoGTM.Trace.TrackAddToCart(codiceProdotto);
    //    }
    //});

    //$(document).on("DeleteProductFromCrossSell", function (event, eventName, codiceProdotto, codiciProdottiCollegati) {
    //    if (codiceProdotto && codiceProdotto != "") {
    //        SkywalkerTracciamentoGTM.Trace.TrackRemoveFromCart(codiceProdotto, codiciProdottiCollegati);
    //    }
    //});

    $(document).on("AddToWishlist", function (event, eventName, codiceProdotto) {
        if (codiceProdotto && codiceProdotto != "") {
            SkywalkerTracciamentoGTM.Trace.TrackAddToWishlist(codiceProdotto);
        }
    });
    // ------------------------------------------------EVENTI ------------------------------------------
};;
