Home › Forums › Product Support Forums › Ajax Search Pro for WordPress Support › Google Analytics Integration
This topic contains 18 replies, has 2 voices, and was last updated by Ernest Marcinko 2 weeks, 2 days ago.
- AuthorPosts
- March 7, 2023 at 10:08 pm #41668
Unable to get the Google Analytics integration to work properly.
Selected… Event Tracking (GTAG & GTM)
Added… Google analytics Tracking ID
Created… Events within Google Analytics accountUncertain what I am doing wrong.
Attachments:
You must be logged in to view attached files.March 8, 2023 at 10:59 am #41672Hi,
You don’t need to create any custom events – the plugin will trigger these events automatically.
If you are using gtag.js integration, then nothing else is required, the events will be fired automatically via the script.
If you use GTM (Gootle Tag Manager), then please check this documentation to setup the triggers, so that GTM can detect and send the events to the selected analytics account.Once the integration is setup correctly, the events will start to appear within the dashboard.
Best,
Ernest Marcinko
If you like my products, don't forget to rate them on codecanyon :)
March 8, 2023 at 3:26 pm #41681Hi Ernest,
I have since removed the custom events. We are using GA4 from Google Analytics. I have placed the related tracking ID into the Ajax Search Pro settings [G-M7J1N5FQZQ].
I am confused then why we haven’t been getting any search event hits presented in Google Analytics?
We have had over 20,000 page views and have been testing the ASP search. This was set up last Monday, so well over that recommended 5 days.
We are getting other events to appear within our GA dashboard (see attached image).
Also attached is a screenshot regarding our settings within the ASP analytics integration.
Sincerely,
BradleyAttachments:
You must be logged in to view attached files.March 8, 2023 at 5:01 pm #41690Okay, everything seems to be adjusted correctly on your end.
I checked the source code, and as if the analytics handler was not detected by the plugin for some reason, but I can’t see exactly why. Can you please try temporarily changing this option: https://i.imgur.com/tdNlO9B.png
It will very likely resolve the issue – however I would like to investigate this further. Can you add temporary FTP and back-end details to access the site and the file system? I would like to directly edit the plugin code to debug why exactly is the analytics handler script missing from the script queue.
Best,
I assume it is something conflicting, usually these types of issues are something very minor (programmatically), but cause a lot of trouble.
Ernest Marcinko
If you like my products, don't forget to rate them on codecanyon :)
March 9, 2023 at 4:24 pm #41705You cannot access this content.March 9, 2023 at 4:43 pm #41706Thank you Bradley!
I logged in, switched back the option to the default “Optimized”, and it works on the dev server, the script is correctly loaded.
I think this might be only a cache related issue then. Can you switch back to the “Optimized” setting on the live site too? After switching please make sure to clear all layers of cache.
Best,
Let me know when you switched back, and I will check the output to see if the analytics script is there.
Ernest Marcinko
If you like my products, don't forget to rate them on codecanyon :)
March 9, 2023 at 7:23 pm #41707I have since switched back to “Optimized” and cleared the cache within ASP, Divi, and WP Engine. Please give this a check.
March 10, 2023 at 9:30 am #41708That did not work, the file is still missing for some reason.
There is one more sequence, that could actually work:
– Open up the search instance settings, and hit the save button without changing anything
– Then on the plugin manager deactivate -> delete the plugin -> upload via the plugin manager and -> activate the plugin again. It is important to upload the plugin again via the plugin manager, and not to use (s)FTP.
Don’t worry, your settings and search bars will not be affected, the data will not be deleted.This sequence will trigger a refresh process in the plugin, which will check the data integrity and recreate the files. Let me know
Best,
Ernest Marcinko
If you like my products, don't forget to rate them on codecanyon :)
March 10, 2023 at 2:55 pm #41709Good day Ernest,
I have since 1) saved the search instance settings and 2) deleted and then uploaded the ASP plugin via the WordPress dashboard.
Please let me know if this is now working as expected.
Sincerely,
BradleyMarch 10, 2023 at 3:19 pm #41710It did not work for some reason. I am out of ideas at the moment, I don’t get why the same exact configuration yields a different output. It must be some sort of a conflict, which does not happen on the other environment, but I can’t se how is that possible.
I cross checked the source code, traced it back completely, and everything seems to be okay, it should work as on the development site.Anyways, if you can somehow allow access to the live after a backup let me know, and I will try to get to the bottom of this. I am 99% sure this is something very minor. Probably a piece of code conflicts somewhere with another piece of code which is very specific for that environment.
If you switch back to the “Classic” script loading, that will resolve the issue, I can see the events firing with that loading method.
Best,
Ernest Marcinko
If you like my products, don't forget to rate them on codecanyon :)
March 10, 2023 at 7:20 pm #41712We do have strict security / security headers on the production website which might be blocking external JS files.
If you know of the external Javascript/jQuery files or library, could you mention them to us so that we could whitelist them?
If requested, we could replicate the same security on the development website that we have set up for you.
March 10, 2023 at 8:52 pm #41714No, everything is local. This issue is much more complicated I’m afraid. I don’t think the security header conflicts with this.
Best,
The plugin gathers the used resources, generates the required javascript file and enqueues it. The generated file contents are correct on the dev site, but somehow incorrect on the live.
Somehow in the “generator” the analytics module is not included – and I don’t see why that happens. After cheking the source code it could only happen if the analytics is disabled, but interestingly the server reports that it is actually enabled.
So it’s basically enabled at one point, disabled at another – which hardly makes any sense, unless there is an issue somewhere, possibly a conflict or something with the data.
Ernest Marcinko
If you like my products, don't forget to rate them on codecanyon :)
March 13, 2023 at 10:20 pm #41742You cannot access this content.March 14, 2023 at 12:00 pm #41752Thank you Bradley, I found the problem 🙂
The difference was created due to the different PHP version, and a yet unknown bug. There is a line in the plugin code, which basically checked if the analytics is disabled by checking if the “choice” does not equal to 0.
Turns out, that generates true on PHP8+ (dev server is running that), but a false statement on all the other versions. It was super hard to find.The fix was very simple, I just added 2 extra characters to the
ajax-search-pro/includes/classes/Asset/Script/Requirements.php
file to check correctly, now the issue is resolved.I will make sure to include this change in the upcoming patch.
Best,
Ernest Marcinko
If you like my products, don't forget to rate them on codecanyon :)
March 14, 2023 at 4:20 pm #41753Thank you Ernest! We deeply appreciate your help.
- AuthorPosts
You must be logged in to reply to this topic.