Google Analytics Integration

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 Ernest Marcinko 1 year ago.

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

    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 account

    Uncertain what I am doing wrong.

    Attachments:
    You must be logged in to view attached files.
    #41672
    Ernest Marcinko
    Ernest Marcinko
    Keymaster

    Hi,

    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 :)


    #41681
    gravocinc
    gravocinc
    Participant

    Hi 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,
    Bradley

    Attachments:
    You must be logged in to view attached files.
    #41690
    Ernest Marcinko
    Ernest Marcinko
    Keymaster

    Okay, 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.
    I assume it is something conflicting, usually these types of issues are something very minor (programmatically), but cause a lot of trouble.

    Best,
    Ernest Marcinko

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


    #41705
    gravocinc
    gravocinc
    Participant
    You cannot access this content.
    #41706
    Ernest Marcinko
    Ernest Marcinko
    Keymaster

    Thank 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.
    Let me know when you switched back, and I will check the output to see if the analytics script is there.

    Best,
    Ernest Marcinko

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


    #41707
    gravocinc
    gravocinc
    Participant

    I have since switched back to “Optimized” and cleared the cache within ASP, Divi, and WP Engine. Please give this a check.

    #41708
    Ernest Marcinko
    Ernest Marcinko
    Keymaster

    That 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 :)


    #41709
    gravocinc
    gravocinc
    Participant

    Good 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,
    Bradley

    #41710
    Ernest Marcinko
    Ernest Marcinko
    Keymaster

    It 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 :)


    #41712
    gravocinc
    gravocinc
    Participant

    We 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.

    #41714
    Ernest Marcinko
    Ernest Marcinko
    Keymaster

    No, everything is local. This issue is much more complicated I’m afraid. I don’t think the security header conflicts with this.
    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.

    Best,
    Ernest Marcinko

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


    #41742
    gravocinc
    gravocinc
    Participant
    You cannot access this content.
    #41752
    Ernest Marcinko
    Ernest Marcinko
    Keymaster

    Thank 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 :)


    #41753
    gravocinc
    gravocinc
    Participant

    Thank you Ernest! We deeply appreciate your help.

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

You must be logged in to reply to this topic.