Viewing 8 posts - 1 through 8 (of 8 total)
  • Author
    Posts
  • #1259253

    Hello, when I ad Google Analytics code in the custom Enfold field then the code is not placed in the header. Is there any way to force Enfold to place the GA code in the header?

    Thanks :)

    Alwin

    #1259359

    Hey Alwin,

    Can you give us temporary admin access to your website in the private content box below, so that we can have a closer look?

    Best regards,
    Victoria

    #1260145

    Hello,
    I’ve the same problem: I need to put the Google analytics code into the header.
    Where/how can I do it.
    Thanks

    <!– Global site tag (gtag.js) – Google Analytics –>
    <script async src=”https://www.googletagmanager.com/gtag/js?id=G-xxxxxxxx”></script&gt;
    <script>
    window.dataLayer = window.dataLayer || [];
    function gtag(){dataLayer.push(arguments);}
    gtag(‘js’, new Date());

    gtag(‘config’, ‘G-xxxxxxxxx’);
    </script>

    #1260254

    Hi,

    Refer to Mike’s post here:

    https://kriesi.at/support/topic/enfold-child-theme-add-google-analytics-code/#post-951578

    Best regards,
    Jordan Shannon

    #1261291

    Hello Jordan,
    I’ve tried and nothing was successful. Google has a new Analytics tool since the 14.10.20.
    Google recommends:
    ___________________________________________
    Add gtag.js to your site
    The global site tag (gtag.js) is a JavaScript tagging framework and API that allows you to send event data to Google Analytics, Google Ads, and Google Marketing Platform. This page describes how to use gtag.js to configure a site for Google Analytics. For general (i.e. non-product specific) gtag.js documentation, read the gtag.js developer guide.

    Install the global site tag
    To install the global site tag, copy the following code and paste it immediately after the <head> tag on every page of your site. Replace GA_MEASUREMENT_ID with the ID of the Google Analytics property to which you want to send data. You need only one global snippet per page.

    <!– Global site tag (gtag.js) – Google Analytics –>
    <script async src=”https://www.googletagmanager.com/gtag/js?id=GA_MEASUREMENT_ID”></script&gt;
    <script>
    window.dataLayer = window.dataLayer || [];
    function gtag(){dataLayer.push(arguments);}
    gtag(‘js’, new Date());

    gtag(‘config’, ‘GA_MEASUREMENT_ID’);
    </script>

    This snippet loads the gtag.js library, establishes GA_MEASUREMENT_ID as the default Google Analytics property ID, and sends a pageview hit to Google Analytics.
    __________________________________________________
    But in enfold child theme there is no header And putting the snippet into the field in in the recommended custom Enfold field it does not work.
    Thanks for looking into that

    #1261296

    Hey,

    Please add following code to bottom of Functions.php file of your child theme in Appearance > Editor

    //-------------------------------
    // Google Analytics code in head section
    //-------------------------------
    
    function av_ga_code_head(){
    ?>
    // Your GA code here
    <?php
    }
    add_action('wp_head', 'av_ga_code_head');

    Our devs are already informed about new GA code issue :)

    Regards,
    Yigit

    #1261303

    Thanks Yigit,
    at the bottom of the child functions.php I find these three last lines.

    </script>
    <?php
    }
    ?>

    Do I need to include the code at the very bottom, or before the <?php ?

    Thanks for your help

    #1261308

    Hey,

    You would need to add your GA code to where it says “// Your GA code here”

    //-------------------------------
    // Google Analytics code in head section
    //-------------------------------
    
    function av_ga_code_head(){
    ?>
    // Your GA code here. REPLACE THIS LINE WITH YOUR CODE 
    <?php
    }
    add_action('wp_head', 'av_ga_code_head');

    Best regards,
    Yigit

Viewing 8 posts - 1 through 8 (of 8 total)
  • You must be logged in to reply to this topic.