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 3 months, 2 weeks ago.
- AuthorPosts
- October 17, 2022 at 4:42 pm #39676
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
October 18, 2022 at 10:22 am #39682Hi 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 :)
October 18, 2022 at 10:37 am #39685Hi 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.October 18, 2022 at 10:50 am #39688(apologies, meant to say, tracking code added to header not footer)
October 18, 2022 at 12:07 pm #39689Okay, 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 :)
October 18, 2022 at 3:26 pm #39692I 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.October 18, 2022 at 3:27 pm #39694(all site/server/browser caches were cleared)
October 18, 2022 at 4:58 pm #39695That 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.
Best,
After installing the new version check the minify/CDN cache as well, that can prevent the files from refreshing.
Ernest Marcinko
If you like my products, don't forget to rate them on codecanyon :)
October 19, 2022 at 9:00 am #39702Hi 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
October 19, 2022 at 1:18 pm #39712I 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.
Best,
Can you please add temporary FTP and back-end access? I would like to debug the code to see what exactly goes wrong.
Ernest Marcinko
If you like my products, don't forget to rate them on codecanyon :)
October 19, 2022 at 2:41 pm #39714Hi 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
October 20, 2022 at 8:48 am #39723Oh 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:
Best,<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>
Ernest Marcinko
If you like my products, don't forget to rate them on codecanyon :)
October 20, 2022 at 9:13 am #39728Hi 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
October 20, 2022 at 9:32 am #39729Okay, 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 :)
October 20, 2022 at 10:13 am #39730Hi 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
- AuthorPosts
You must be logged in to reply to this topic.