Viewing 11 posts - 1 through 11 (of 11 total)
  • Author
    Posts
  • #1259700

    Gday Enfold users and support,
    I have added the new GA4 tracking code to the Google Services area, but is not collecting data.
    Are there any known issues with this, or special integration methods?
    Thanks for any help you can provide, much appreciated.
    My login details provided for Enfold support.
    cheers
    Darryl

    #1259798

    Hey Darryl,

    It’s not working on a local installation either when I try to reproduce the problem, so there’s likely an issue with how we handle that type of code. I’ve reported this to our developers, but I don’t have a solution for you right now though.

    Until we have a solution then you can try adding it using a function in functions.php instead:

    function new_google_analytics(){
    ?>
    //Your code goes here
    <?php
    }
    add_action('wp_head', 'new_google_analytics');

    Best regards,
    Rikard

    #1259799

    Gday Rikard, thank you for your investigation, and your suggestion, very much appreciated. I’ll try that and will write back with the results.
    cheers
    Darryl

    #1259851

    Gday Rikard
    Thanks again for your help with this. I added to my child functions file and the code is coming through in the head, but still not collecting at Analytics. The advice in the Google admin is to add the code as the very first item in the head. I’m not a coder, so I searched on how to do that but no luck. Do you know how to modify that function code to make the script first in the head?
    Thanks Rikard, I understand this is moving out of Enfold support per se, so any help at all is much appreciated.
    cheers
    Darryl

    #1260062

    Hi Darryl,

    Please try this instead, it should give it the highest priority:

    function new_google_analytics(){
    ?>
    //Your code goes here
    <?php
    }
    add_action('wp_head', 'new_google_analytics', 1);

    Documentation can be found here: https://developer.wordpress.org/reference/hooks/wp_head/

    Best regards,
    Rikard

    • This reply was modified 3 years, 7 months ago by Rikard.
    #1267747

    Hi Darryl,

    After integrating the give code into the functions.php file the website does not work correctly.

    A while line above the menu has appeared with the tracking code in it. Could you please take a look at it if possible?

    Alexander

    #1267775

    Hi Darryl,

    Please disregard my previous message. The functions.php code did not work completely. So I have removed it from the website.

    Alex

    #1267777

    Hi AT_VALENS,

    Can you please share the code that you were adding?

    Best regards,
    Victoria

    #1267790

    Ok,

    For the very smart people like myself:

    This is how the complete version of the code inserted into the functions.php should look like. Hope this saves times to someone new to this too.

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

    gtag(‘config’, ‘G-00XXX0X0XX’);
    </script>
    <?php
    }
    add_action(‘wp_head’, ‘new_google_analytics’, 1);

    Alex

    #1267793

    Apologies for bothering you for nothing really

    #1267806

    Hi AT_VALENS,

    I’m glad you got it working for you and thank you for sharing :)

    You did not bother us for nothing as we are here to help.

    If you need further assistance please let us know.
    Best regards,
    Victoria

Viewing 11 posts - 1 through 11 (of 11 total)
  • The topic ‘Integrating new GA4 Analytics code’ is closed to new replies.