Google Analytics Issues?

  • mcl7
    Participant
    # 1 year, 3 months ago

    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 1 year, 3 months ago by wpsolr.
    wpsolr
    Keymaster
    # 1 year, 3 months ago

    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
    # 1 year, 3 months ago

    Thank you!

    wpsolr
    Keymaster
    # 1 year, 3 months ago
    mcl7
    Participant
    # 1 year, 2 months ago

    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
    # 1 year, 2 months ago

    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 1 year, 2 months ago by wpsolr.
    mcl7
    Participant
    # 1 year, 2 months ago

    Would you place in this in the head or body?

    wpsolr
    Keymaster
    # 1 year, 2 months ago

    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 1 year, 2 months ago by wpsolr.
Viewing 8 posts - 1 through 8 (of 8 total)

You must be logged in to reply to this topic.