Google Analytics Issues?

  • mcl7
    Participant
    3 years, 1 month ago #25102

    I can confirm that, at least on my end, filtered URLs are being tracked in GA only when I actually refreshed the entire page. If I just filter the page, the actual filtered URL that WPsolr produces does not get recorded in GA.

    Anyone else seeing this?

    • This topic was modified 3 years, 1 month ago by wpsolr.
    wpsolr
    Keymaster
    3 years, 1 month ago #25107

    After every Ajax call, WPSOLR sends a js event:
    jQuery(document).trigger('wpsolr_on_ajax_success');

    You can catch this event and track it with your Google Analytic:

    jQuery(document).on('wpsolr_on_ajax_success', function (event) {
        // GA tracking code here
    });
    mcl7
    Participant
    3 years, 1 month ago #25117

    Thank you!

    wpsolr
    Keymaster
    mcl7
    Participant
    3 years ago #25950

    I put this on the back burner but picking it back up again. First of all, thank you for the code.

    I wanted to add to this that the Google Analytics tracking for filter URLs does actually work but ONLY when you do a hard refresh (or paste the URL in a new browser tab). This makes sense because without the hard refresh the GA code doesn’t fire and therefore the pageview is not passed to GA. However, when you reload the whole page of course it does and without modifying any code we see the page views reported in GA just fine.

    It’s only when refreshing just the result set that the page view is not passed. We played with the code you provided attempting different implementations to solve this but no luck.

    While we were going through – and saw the pageviews being reported in GA on a hard refresh – I started to question if the code you provided would result in a double count on a hard refresh (single pageview count if only using the filter which ideally fires your code)?

    Any ideas here?

    wpsolr
    Keymaster
    3 years ago #25953

    The js custom event ‘wpsolr_on_ajax_success’ is triggered once, just after the Ajax call and url update. But only when clicking on a facet.
    Refreshing the page does not trigger the event.

    You should be able to confirm that with:

    jQuery(document).on('wpsolr_on_ajax_success', function (event) {
        console.log('hello');
    });
    • This reply was modified 3 years ago by wpsolr.
    mcl7
    Participant
    3 years ago #25971

    Would you place in this in the head or body?

    wpsolr
    Keymaster
    3 years ago #26023

    Sorry, but I cannot answer to implementation specific details.
    There is an idea to build a Google Analytics add-on in WPSOLR, but nothing committed yet.

    • This reply was modified 3 years ago by wpsolr.
Viewing 8 posts - 1 through 8 (of 8 total)

You must be logged in to reply to this topic.