• Resolved Vitaio

    (@vitaio)


    Dear Customer Support,

    Is it possible to implement the following code on the site without placing it in the header.php file or using an external plugin? I primarily use Elementor to build the site, but when I insert the code below with priority 1 under the Elementor – Custom Code menu, several other codes (such as the Google Analytics code from the Site Kit plugin) run before it. As far as I understand, the code below needs to run first. Can you help me solve this issue?

    <script>

        window.dataLayer = window.dataLayer || [];

        function gtag() {

            dataLayer.push(arguments);

        }

        gtag("consent", "default", {

            ad_storage: "denied",

            ad_user_data: "denied",

            ad_personalization: "denied",

            analytics_storage: "denied",

            functionality_storage: "denied",

            personalization_storage: "denied",

            security_storage: "granted",

            wait_for_update: 2000,

        });

        gtag("set", "ads_data_redaction", true);

        gtag("set", "url_passthrough", true);

            </script>

    The page I need help with: [log in to see the link]

Viewing 2 replies - 1 through 2 (of 2 total)
  • Plugin Support CookieYes Team

    (@cookieyesteam)

    Hi @vitaio,

    Greetings from CookieYes!

    Please try the code snippet below by copying it to your site’s active child themes functions.php file.

    add_action('wp_head', 'cky_add_script_to_head', -1);
    function cky_add_script_to_head() {
    ?>
    <script>
    window.dataLayer = window.dataLayer || [];
    function gtag() {
    dataLayer.push(arguments);
    }
    gtag("consent", "default", {
    ad_storage: "denied",
    ad_user_data: "denied",
    ad_personalization: "denied",
    analytics_storage: "denied",
    functionality_storage: "denied",
    personalization_storage: "denied",
    security_storage: "granted",
    wait_for_update: 2000,
    });
    gtag("set", "ads_data_redaction", true);
    gtag("set", "url_passthrough", true);
    </script>
    <?php
    }
    Thread Starter Vitaio

    (@vitaio)

    Thanks for your help, it works fine.

Viewing 2 replies - 1 through 2 (of 2 total)

The topic ‘CookieYes script integration with Elementor Custom Code’ is closed to new replies.