Google Analytics Issues?
- mcl7Participant3 years, 7 months 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, 7 months ago by wpsolr.
wpsolrKeymaster3 years, 7 months ago #25107After 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 });
wpsolrKeymaster3 years, 7 months ago #25123I added Analytics to the roadmap: https://trello.com/c/ROUtWxVz/143-integrate-with-analytic-solutions-like-gg-analytics
mcl7Participant3 years, 5 months ago #25950I 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?
wpsolrKeymaster3 years, 5 months ago #25953The 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, 5 months ago by wpsolr.
wpsolrKeymaster3 years, 5 months ago #26023Sorry, 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, 5 months ago by wpsolr.
You must be logged in to reply to this topic.