Google Analytics Event Tracking broken?

Home Forums Product Support Forums Ajax Search Pro for WordPress Support Google Analytics Event Tracking broken?

This topic contains 18 replies, has 2 voices, and was last updated by Ernest Marcinko Ernest Marcinko 3 months, 2 weeks ago.

Viewing 15 posts - 1 through 15 (of 19 total)
  • Author
    Posts
  • #39676
    flashjunkie
    flashjunkie
    Participant

    Hi there,

    We have recently updated our website and have changed the way our search bars work, rather than using a search results page we are using a drop down search. I tried to activate the events tracker in the plugin but unfortunately it does not seem to be working?

    I am using the google analytics debug tool in chrome and the events are not being triggered, other events around the website such as click events etc are firing as expected.

    Our URL is tpet.co.uk

    Many thanks for your help

    Jason

    #39682
    Ernest Marcinko
    Ernest Marcinko
    Keymaster

    Hi Jason,

    I just checked the website, but I don’t see the google analytics tracking code installed anywhere – that is the cause of the issue. Make sure the tracking code is installed, then the events tracking will start working.

    Best,
    Ernest Marcinko

    If you like my products, don't forget to rate them on codecanyon :)


    #39685
    flashjunkie
    flashjunkie
    Participant

    Hi ernest,

    Gtag is in place, it was being loaded by the PYS plugin, however I have disabled that and placed it directly in the footer of the website as shown.

    Whilst debugging I am still not getting any ASP events being shown.

    Many thanks

    Attachments:
    You must be logged in to view attached files.
    #39688
    flashjunkie
    flashjunkie
    Participant

    (apologies, meant to say, tracking code added to header not footer)

    #39689
    Ernest Marcinko
    Ernest Marcinko
    Keymaster

    Okay, are you using the latest version of the plugin? Current version is 4.23.4. The console tells me it is an older version, can you please update and clear all layers of site cache? It will very likely resolve the issue.

    Best,
    Ernest Marcinko

    If you like my products, don't forget to rate them on codecanyon :)


    #39692
    flashjunkie
    flashjunkie
    Participant

    I updated to the latest version but got a new error (see screenshot) – this happened any time I try to search. Rolled back to previous version and the bug is gone but still no luck with the events on GA.

    Many thanks,

    Jay

    Attachments:
    You must be logged in to view attached files.
    #39694
    flashjunkie
    flashjunkie
    Participant

    (all site/server/browser caches were cleared)

    #39695
    Ernest Marcinko
    Ernest Marcinko
    Keymaster

    That message means, that a cache was not cleared unfortunately. The old script of the plugin code was loaded up via the browser, and it could not handle the request from the new release server side query.
    After installing the new version check the minify/CDN cache as well, that can prevent the files from refreshing.

    Best,
    Ernest Marcinko

    If you like my products, don't forget to rate them on codecanyon :)


    #39702
    flashjunkie
    flashjunkie
    Participant

    Hi again,

    Thanks for that, i reinstalled the update and cleared the min cache for the plugin and the search is working with the update however I’m still not receiving the ASP events for GA.

    Many thanks

    #39712
    Ernest Marcinko
    Ernest Marcinko
    Keymaster

    I honestly don’t know then – I tried to replicate, but everything works fine on all of our test servers (on live too), so it is something very specific.
    Can you please add temporary FTP and back-end access? I would like to debug the code to see what exactly goes wrong.

    Best,
    Ernest Marcinko

    If you like my products, don't forget to rate them on codecanyon :)


    #39714
    flashjunkie
    flashjunkie
    Participant

    Hi Ernesto,

    Unfortunately due to our privacy policies and dealing with school and child information we are prohibited from providing said access.

    The only plugin I could think may be interfering would be the Pixel Your Site plugin which we use extensively for inputting custom JS & CSS into pages etc. Perhaps there is a conflict here?

    Since updating to the latest version we have a new bug, we have 24 results per page as per our pagination, however, it is only pulling in 23 results per page.

    Many thanks

    Jason

    #39723
    Ernest Marcinko
    Ernest Marcinko
    Keymaster

    Oh I see the problem now, the gtag tracking code is not loaded properly. The actual gtag.js is not queued. I see you have this in your site header:

    function gtag(){window.dataLayer.push(arguments);}
      gtag('js', new Date());
    
      gtag('config', 'UA-141577790-1');

    ..however this does not do anything at all, besides generating an empty gtag function. The proper integration should be:

    <script async src="https://www.googletagmanager.com/gtag/js?id=UA-141577790-1"></script>
    <script>
      window.dataLayer = window.dataLayer || [];
      function gtag(){window.dataLayer.push(arguments);}
      gtag('js', new Date());
    
      gtag('config', 'UA-141577790-1');
    </script>

    You only have the second script part implemented, which is not sufficent. If you are concerned about the google pagespeed scores, then we are using a custom made implementation of this, which has 0 impact on the web vitals score, it is super fast an asynchronous:

    <script>
        window.dataLayer = window.dataLayer || [];
        if (navigator.userAgent.indexOf("Chrome-Lighthouse") === -1) {
            let _gscript = document.createElement('script'),
                _gtcode = 'UA-141577790-1';
            _gscript.src = 'https://www.googletagmanager.com/gtag/js?id='+_gtcode;
            document.body.appendChild(_gscript);
    
            function gtag(){dataLayer.push(arguments);}
            gtag('js', new Date());
            gtag('config', _gtcode);
        }
    </script>
    Best,
    Ernest Marcinko

    If you like my products, don't forget to rate them on codecanyon :)


    #39728
    flashjunkie
    flashjunkie
    Participant

    Hi Ernest,

    I have implemented this script in the head of the website, thanks for working with me on this. I’m still not seeing any events in the console when using the debug tool. i see a lot of ‘clickevent’ and ‘form’ events but nothing with the ASP event category.

    Cheers

    Jason

    #39729
    Ernest Marcinko
    Ernest Marcinko
    Keymaster

    Okay, that looks all right from the console, the script is definitely loaded.

    Let’s try something else. Can you switch the script loading method to classic here: https://i.imgur.com/xho3Z9K.png

    Best,
    Ernest Marcinko

    If you like my products, don't forget to rate them on codecanyon :)


    #39730
    flashjunkie
    flashjunkie
    Participant

    Hi ernest,

    Ok, that seems to be working I’m now seeing ASP events for ‘focus’ ‘end’ etc in the GA debug tool.

    However, I’m now getting a type error in relation to the script snippet i inserted into the head that you recommended.

    I have removed the snippet entirely and the events still seem to be working ok, I think the PYS plugin loads the GA scripts so were not needed to be set explicitly in this way.

    Obviously, I’m not keen on blocking scripts, is there a workaround to have the events code work with the optimised setting?

    Many thanks,

    Jason

Viewing 15 posts - 1 through 15 (of 19 total)

You must be logged in to reply to this topic.