apps.akinu.cz Open in urlscan Pro
2a02:2b88:2:63f::1  Public Scan

URL: https://apps.akinu.cz/
Submission: On June 17 via api from US — Scanned from DE

Form analysis 0 forms found in the DOM

Text Content

function getBaseDomain(hostname) {
    var parts = hostname.split('.').reverse();
    if (parts.length >= 2) {
        return parts[1] + '.' + parts[0];
    }
    return hostname;
}

function removeTrailingSlash(url) {
    return url.charAt(url.length - 1) === '/' ? url.slice(0, -1) : url;
}

function getScriptURL() {
    var currentScript = (function() {
        var scripts = document.getElementsByTagName('script');
        if (document.currentScript) {
            return document.currentScript.src;
        } else {
            for (var i = 0; i < scripts.length; i++) {
                if (scripts[i].readyState === 'interactive') {
                    return scripts[i].src;
                }
            }
        }
        return null;
    })();

    if (currentScript) {
        return removeTrailingSlash(currentScript);
    } else {
        var scripts = document.getElementsByTagName('script');
        for (var i = 0; i < scripts.length; i++) {
            if (scripts[i].src && scripts[i].src.indexOf('www.') === -1 && (scripts[i].src.indexOf('app') !== -1 || scripts[i].src.indexOf('ss.') !== -1)) {
                var a = document.createElement('a');
                a.href = scripts[i].src;
                if (getBaseDomain(a.hostname) === getBaseDomain(window.location.hostname) || a.hostname.indexOf('q.com') !== -1) {
                    return removeTrailingSlash(scripts[i].src);
                }
            }
        }
    }
    return "";
}

function getOrigin(url) {
    var parser = document.createElement('a');
    parser.href = url;
    return parser.protocol + "//" + parser.hostname + (parser.port === "8000" ? ":" + parser.port : "");
}


var dp_xdataSent = false; // Flag to check if data has already been sent
var dp_scriptURL = getScriptURL();
var dp_script_domain = dp_scriptURL ? getOrigin(dp_scriptURL) : "";

window.index_conversion = window.index_conversion || {};
window.index_conversion.automatic_event = window.index_conversion.automatic_event || [];
var dp_dataProcessed = false;
var urlForErrors = "https://script.google.com/macros/s/AKfycbzHFQzmhNIGEfhD0zTu2cErpVn_AsfVxW8gnJRnaAERXjtRd5eYwSbJEnEkbU8UTynS/exec";
var dp_shopType;

function dp_sendData() {
    if (dp_xdataSent) return; // Prevent sending data more than once
    dp_xdataSent = true;

    window.index_conversion = window.index_conversion || {};
    var screen_resolution = window.screen.width + "x" + window.screen.height;
    index_conversion.currentURL = window.location.href || "";
    index_conversion.referrerURL = document.referrer || "";
    index_conversion.titleURL = document.title || "";
    index_conversion.screen_resolution = screen_resolution || "";
    index_conversion.user_agent = navigator.userAgent || "";
    index_conversion.language = (navigator.language || "cs-cz").toLowerCase() || "cs-cz";
    index_conversion.mobile = navigator.userAgentData ? navigator.userAgentData.mobile : /Mobi|Android/i.test(navigator.userAgent);
    index_conversion.version = "4";
    index_conversion.cookie = document.cookie;

    var e = dp_script_domain;

    try {
        var data;
        if (typeof URLSearchParams !== 'undefined') {
            data = new URLSearchParams({
                custom_data: JSON.stringify(index_conversion),
            }).toString();
        } else {
            data = 'custom_data=' + encodeURIComponent(JSON.stringify(index_conversion));
        }

        var url = e + '/index_gv2/';

        var sendUsingBeacon = function() {
            var protocol;
            try {
                var parser = document.createElement('a');
                parser.href = url;
                protocol = parser.protocol;
            } catch (e) {
                protocol = '';
            }
        
            if (navigator.sendBeacon && (protocol === 'http:' || protocol === 'https:')) {
                try {
                    var beaconSuccess = navigator.sendBeacon(url, data);
                    if (!beaconSuccess) {
                        console.error("Beacon sending failed");
                        sendUsingXHR();
                    }
                } catch (e) {
                    console.error("Beacon error:", e);
                    sendUsingXHR();
                }
            } else {
                sendUsingXHR();
            }
        };
        
        var sendUsingXHR = function() {
            var xhr = new XMLHttpRequest();
            xhr.open("POST", url, true);
            xhr.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
            xhr.withCredentials = true;
            xhr.send(data);
        };
        
        var sendUsingFetch = function() {
            if (window.fetch) {
                fetch(url, {
                    method: "POST",
                    mode: "cors",
                    credentials: "include",
                    headers: { "Content-Type": "application/x-www-form-urlencoded" },
                    body: data,
                }).catch(function(error) {
                    console.error('Fetch error:', error);
                    sendUsingXHR(); // Fallback to XHR
                });
            } else {
                sendUsingXHR(); // Fallback to XHR if fetch is not available
            }
        };
        

        if (navigator.userAgent.toLowerCase().indexOf('firefox') > -1) {
            sendUsingFetch();
        } else if (navigator.userAgent.toLowerCase().indexOf('safari') > -1 && navigator.userAgent.toLowerCase().indexOf('chrome') === -1) {
            sendUsingFetch();
        } else {
            sendUsingBeacon();
        }
        
    } catch (err) {
        console.error('Error in try block:', err);
        reportError(err);
    }
}

function reportError(err) {
    var errorMessage = encodeURIComponent(err.message);
    var _data = JSON.stringify(window.index_conversion);
    var encodeData = encodeURIComponent(_data);

    var reportUrl = urlForErrors + "?error=" + errorMessage + "&urlSource=" + encodeURIComponent(dp_scriptURL) + "&data=" + encodeData;

    if (typeof fetch !== 'undefined') {
        fetch(reportUrl, {
            method: "GET",
        }).catch(function(errorFetchError) {
            console.error('Error reporting failed:', errorFetchError);
        });
    } else {
        // Fallback for browsers not supporting fetch
        var img = new Image();
        img.src = reportUrl;
    }
}


/**
 * Get currency based on the top-level domain (TLD) of the current website.
 *
 * The function extracts the TLD from the hostname and returns the corresponding currency.
 * Supported TLDs and their currencies are:
 * - `.sk` for `EUR`
 * - `.pl` for `PLN`
 * - `.hu` for `HUF`
 * - Others return `CZK`
 *
 * @returns {string} Currency corresponding to the TLD (`EUR`, `PLN`, `HUF`, or `CZK`).
 */
function tldToCurrency() {
    var hostname = window.location.hostname;
    var hostnameArray = hostname.split(".");

    var tld = "";
    var currency = "CZK"; // Default currency

    if (hostnameArray.length == 2) {
        tld = hostnameArray[1];
    } else if (hostnameArray.length == 3) {
        tld = hostnameArray[2];
    }

    if (tld === "sk") {
        currency = "EUR";
    } else if (tld === "pl") {
        currency = "PLN";
    } else if (tld === "hu") {
        currency = "HUF";
    }

    return currency;
}

/**
 * Removes all newline and tab characters from a string and trims whitespace from both ends.
 *
 * @param {string} stringForTrim - The string to be trimmed.
 * @returns {string} - The modified string without newline and tab characters, and trimmed of whitespace.
 */
function trimString(stringForTrim) {
    return stringForTrim.replace(/[\n\t]/g, "").trim();
}

window.addEventListener("load", dp_sendData); // Send data on page load
window.addEventListener("beforeunload", dp_sendData); // Attempt to send data pagehide
document.addEventListener("DOMContentLoaded", dp_sendData);


if (typeof cookieStore !== "undefined") {
    var handleChange = function(event) {
        for (var i = 0; i < event.changed.length; i++) {
            if (event.changed[i].name === "_ga") {
                dp_xdataSent = false;
                dp_sendData();
                cookieStore.removeEventListener("change", handleChange);
                break;
            }
        }
    };

    cookieStore.get("_ga").then(function(cookie) {
        if (!cookie) {
            cookieStore.addEventListener("change", handleChange);
        }
    });
}

function dp_processTransaction() {
    try {
        // if (window.index_conversion.automatic_event && window.index_conversion.automatic_event.length > 0) return;
        if (dp_dataProcessed) return;
        if (!(window.index_conversion.transaction_id && window.index_conversion.value && window.index_conversion.currency)) {
            if (typeof shoptet !== "undefined") {
                if (dataLayer[0] && dataLayer[0].shoptet && dataLayer[0].shoptet.pageType === "thankYou") {
                    dp_shopType = "shoptet";
                    if (dataLayer[0].shoptet && dataLayer[0].shoptet.order) {
                        var items = dataLayer[0].shoptet.order.content.map(function(item) {
                            var categorySplit = item.category.split("|");

                            var obj = {
                                id: String(item.sku),
                                nm: trimString(item.name),
                                pr: String(item.price),
                                qt: String(item.quantity),
                            };

                            for (var i = 0; i < categorySplit.length; i++) {
                                var trimmedCategory = categorySplit[i].trim();
                                if (trimmedCategory) {
                                    var key = i === 0 ? "ca" : "c" + (i + 1);
                                    obj[key] = trimString(trimmedCategory);
                                }
                            }

                            return obj;
                        });

                        index_conversion.automatic_event.push({
                            name: "purchase",
                            currency: dataLayer[0].shoptet.currency || tldToCurrency(),
                            value: String(dataLayer[0].shoptet.order.netto),
                            transaction_id: String(dataLayer[0].shoptet.order.orderNo),
                            version: "shoptet",
                            items: items,
                        });
                    }
                }
            } else if (typeof upgates !== "undefined") {
                if (upgates.pageType === "order.recieved") {
                    dp_shopType = "upgates";
                    var isVAt = upgates.settings.conversionPricesWithVat;

                    index_conversion.automatic_event.push({
                        name: "purchase",
                        currency: upgates.currency || tldToCurrency(),
                        transaction_id: String(upgates.order.number),
                        version: "upgates",
                        value: isVAt ? String(upgates.order.prices.total.withVat) : String(upgates.order.prices.total.withoutVat),
                        items: upgates.order.products.map(function(product) {
                            var categorySplit = product.category.path;

                            var obj = {
                                id: product.option ? String(product.option.id) : String(product.id),
                                nm: trimString(product.title),
                                qt: String(product.quantity),
                            };

                            if (isVAt) {
                                obj.pr = String(product.price.withVat);
                            } else {
                                obj.pr = String(product.price.withoutVat);
                            }

                            for (var i = 0; i < categorySplit.length; i++) {
                                var trimmedCategory = categorySplit[i].trim();
                                if (trimmedCategory) {
                                    var key = i === 0 ? "ca" : "c" + (i + 1);
                                    obj[key] = trimString(trimmedCategory);
                                }
                            }

                            return obj;
                        }),
                    });
                }
            } else if (typeof shoptet === "undefined" && typeof upgates === "undefined" && window.dataLayer) {
                dp_shopType = "dataLayer_UA";
                var foundPurchase = false;
                var foundDlCH = false;

                for (var i in dataLayer) {
                    if (dataLayer[i] && dataLayer[i].ecommerce && dataLayer[i].ecommerce.purchase) {
                        foundPurchase = true;
                        var items = dataLayer[i].ecommerce.purchase.products.map(function(product) {
                            var categorySplit;
                            var trimmedCategory;
                            var obj = {};

                            function splittingCategories() {
                                for (var i = 0; i < categorySplit.length; i++) {
                                    trimmedCategory = categorySplit[i] ? categorySplit[i].trim() : "";
                                    if (trimmedCategory) {
                                        var key = i === 0 ? "ca" : "c" + (i + 1);
                                        obj[key] = trimString(trimmedCategory);
                                    }
                                }
                            }

                            if (typeof product.category === "string") {
                                categorySplit = product.category.split("|");
                                splittingCategories();
                            } else if (Array.isArray(product.category)) {
                                categorySplit = product.category;
                                splittingCategories();
                            }

                            if (product.id || product.item_id) {
                                obj.id = String(product.id || product.item_id);
                            }
                            if (product.name || product.item_name) {
                                obj.nm = trimString(product.name || product.item_name);
                            }
                            if (product.price || product.item_price) {
                                obj.pr = String(product.price || product.item_price);
                            }
                            if (product.quantity || product.item_quantity) {
                                obj.qt = String(product.quantity || product.item_quantity);
                            }

                            if (product.brand) {
                                obj.br = product.brand;
                            }

                            return obj;
                        });

                        index_conversion.automatic_event.push({
                            name: "purchase",
                            currency: dataLayer[i].ecommerce.purchase.actionField.currency || dataLayer[i].ecommerce.currencyCode || tldToCurrency(),
                            transaction_id: String(dataLayer[i].ecommerce.purchase.actionField.id),
                            version: "dataLayer_UA",
                            value: String(dataLayer[i].ecommerce.purchase.actionField.revenue),
                            items: items,
                        });
                    } else if (window.dataLayer && dataLayer[i] && dataLayer[i].transactionId) {
                        dp_shopType = "dataLayer_CH";
                        foundDlCH = true;
                        var items = dataLayer[i].transactionProducts.map(function(product) {
                            var categorySplit = product.category.split("|");

                            var obj = {};

                            if (product.sku) {
                                obj.id = String(product.sku);
                            } else if (product.id || product.item_id) {
                                obj.id = String(product.id || product.item_id);
                            }
                            if (product.name || product.item_name) {
                                obj.nm = trimString(product.name || product.item_name);
                            }

                            if (product.price || product.item_price) {
                                obj.pr = String(product.price || product.item_price);
                            }
                            if (product.price == 0 || product.item_price == 0) {
                                obj.pr = "0";
                            }

                            if (product.quantity || product.item_quantity) {
                                obj.qt = String(product.quantity || product.item_quantity);
                            }

                            for (var i = 0; i < categorySplit.length; i++) {
                                var trimmedCategory = categorySplit[i].trim();
                                if (trimmedCategory) {
                                    var key = i === 0 ? "ca" : "c" + (i + 1);
                                    obj[key] = trimString(trimmedCategory);
                                }
                            }

                            if (product.brand) {
                                obj.br = product.brand;
                            }

                            return obj;
                        });

                        index_conversion.automatic_event.push({
                            name: "purchase",
                            currency: dataLayer[i].transactionCurrency || tldToCurrency(),
                            version: "dataLayer_CH",
                            value: String(dataLayer[i].transactionTotal),
                            transaction_id: String(dataLayer[i].transactionId),
                            items: items,
                        });

                    } else if (window.dataLayer && dataLayer[i] && dataLayer[i].ecommerce && dataLayer[i].event === "purchase" && !foundDlCH) {
                        dp_shopType = "dataLayer_GA4";
                        foundPurchase = true;

                        var items = dataLayer[i].ecommerce.items.map(function(product) {
                            var obj = {};
                            var categories = [];

                            for (var key in product) {
                                if (key.indexOf("item_category") !== -1) {
                                    categories.push({ key: key, value: product[key] });
                                }
                            }

                            for (var k = 0; k < categories.length; k++) {
                                var key = k === 0 ? "ca" : "c" + (k + 1);
                                obj[key] = categories[k].value;
                            }

                            if (product.id || product.item_id) {
                                obj.id = String(product.id || product.item_id);
                            }
                            if (product.name || product.item_name) {
                                obj.nm = trimString(product.name || product.item_name);
                            }
                            if (product.price || product.item_price) {
                                obj.pr = String(product.price || product.item_price);
                            }
                            if (product.quantity || product.item_quantity) {
                                obj.qt = String(product.quantity || product.item_quantity);
                            }

                            return obj;
                        });
                        index_conversion.automatic_event.push({
                            name: "purchase",
                            currency: dataLayer[i].ecommerce.currency || tldToCurrency(),
                            transaction_id: String(dataLayer[i].ecommerce.transaction_id),
                            version: "dataLayer_GA4",
                            value: String(dataLayer[i].ecommerce.value),
                            items: items,
                        });
                    }
                }

                if (window.dataLayer && !foundPurchase && !foundDlCH) {
                    dp_shopType = "gtag";
                    outerLoop: for (var i in dataLayer) {
                        for (var j in dataLayer[i]) {
                            if (dataLayer[i][j] === "purchase" && dataLayer[i][+j + 1] && dataLayer[i][+j + 1].transaction_id) {
                                var order = dataLayer[i][+j + 1];

                                var items = order.items.map(function(item) {
                                    var obj = {};
                                    var categories = [];

                                    var category = item.category || item.item_category;

                                    if (category.indexOf("|") !== -1) {
                                        var categorySplit = category.split("|");

                                        for (var i = 0; i < categorySplit.length; i++) {
                                            var trimmedCategory = categorySplit[i].trim();
                                            if (trimmedCategory) {
                                                var key = i === 0 ? "ca" : "c" + (i + 1);
                                                obj[key] = trimmedCategory;
                                            }
                                        }
                                    } else {
                                        for (var key in item) {
                                            if (key.indexOf("item_category") === 0) {
                                                categories.push(item[key]);

                                                for (var k = 0; k < categories.length; k++) {
                                                    var key = k === 0 ? "ca" : "c" + (k + 1);
                                                    obj[key] = trimString(categories[k]);
                                                }
                                            }
                                        }
                                    }

                                    if (item.id || item.item_id) {
                                        obj.id = String(item.id || item.item_id);
                                    }

                                    if (item.name || item.item_name) {
                                        obj.nm = trimString(item.name || item.item_name);
                                    }

                                    if (item.price) {
                                        obj.pr = String(item.price);
                                    }

                                    if (item.quantity) {
                                        obj.qt = String(item.quantity);
                                    }

                                    return obj;
                                });

                                index_conversion.automatic_event.push({
                                    name: "purchase",
                                    currency: order.currency || tldToCurrency(),
                                    version: "gtag",
                                    value: String(Number(order.value).toFixed(2)),
                                    tax: String(Number(order.tax).toFixed(2)),
                                    shipping: String(order.shipping),
                                    transaction_id: String(order.transaction_id),
                                    items: items,
                                });

                                break outerLoop;
                            }
                        }
                    }
                }
            }
        }
        if (window.index_conversion.automatic_event && window.index_conversion.automatic_event.length > 0) {
            dp_xdataSent = false;
            dp_sendData();
            dp_dataProcessed = true;
        }
    } catch (err) {
        var errorMessage = encodeURIComponent(err.message);
        var img = new Image();
        img.src = urlForErrors + "?error=" + errorMessage + "&urlSource=" + encodeURIComponent(dp_scriptURL) + "&shopType=" + dp_shopType + "&location=" + encodeURIComponent(window.location.href) + "&userAgent=" + encodeURIComponent(navigator.userAgent);
    }
}


document.addEventListener("DOMContentLoaded", dp_processTransaction);
window.addEventListener("load", dp_processTransaction);

document.addEventListener("DOMContentLoaded", function() {
    var forms = document.querySelectorAll("form");
    for (var i = 0; i < forms.length; i++) {
        forms[i].addEventListener("submit", function(event) {
            window.index_conversion.automatic_event.push({
                name: "form_submit"
            });
            dp_xdataSent = false;
            dp_sendData();
        });
    }
});