Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
Looks like there is a new feature in GA that may prevent losing tracking hits. https://developers.google.com/analytics/devguides/collection/analyticsjs...
ga('send', 'event', 'click', 'download-me', {'transport': 'beacon'});
Comment | File | Size | Author |
---|---|---|---|
#29 | Issue-2355091-by-hass-Add-transport-beacon-for-more-.patch | 8.24 KB | hass |
Comments
Comment #1
hass CreditAttribution: hass commentedComment #2
hass CreditAttribution: hass commentedComment #3
hass CreditAttribution: hass commentedComment #4
hass CreditAttribution: hass commentedComment #5
albertski CreditAttribution: albertski commentedIt would be nice to use useBeacon but unfortunately Internet Explorer and Safari does not support navigator.sendBeacon(). https://developer.mozilla.org/en-US/docs/Web/API/navigator.sendBeacon#Br...
Comment #6
hass CreditAttribution: hass commentedI'm aware of the browser compatibilty, but the JS code falls back automatically. This means it doesn't matter and it works the old way on the other browsers. Google seems to have realized the issues we faced in #1580144: Links not tracked in some browsers as jquery click event exits before tracking code finishes
I only wonder why the hell Google is not enabling
useBeacon
by default. Maybe it's not working properly and they try to find beta testers this way...!?!??Comment #7
albertski CreditAttribution: albertski commented"If the browser does not support navigator.sendBeacon, the hit will be sent normally." meaning the problem remains for IE and Safari. Why can't everyone just use Chrome :)
Comment #8
hass CreditAttribution: hass commentedChrome is piece of crap if it comes to Enterprise support.
Comment #9
chipk CreditAttribution: chipk commentedTested Issue-2355091-Add-useBeacon-to-outbound-links.patch (comment #4) against 8.x-2.x (commit 42ed87a7d04a331e4fc). First had to apply google_analytics-attaching-inline-js-no-longer-possible-2391029-9.patch to fix broken baseline functionality. I created a node with an external link and stepped through google_analytics.js, confirming that the call configured with useBeacon resulted in the external link being logged in Analytics, as viewed in the Real-Time console.
Comment #10
hass CreditAttribution: hass commentedComment #12
hass CreditAttribution: hass commentedComment #13
hass CreditAttribution: hass commentedJust a note how this functionality can verified. In network analysis the beacons become a POST request where it normally is a GET.
Comment #14
Simon Georges CreditAttribution: Simon Georges at Makina Corpus commentedIs it
{useBeacon: true}
or{transport: beacon}
? https://github.com/h5bp/html5-boilerplate/pull/1696#issuecomment-96120785 (by the way, this thread is very detailed regarding best loading practices for analytics ;-)Comment #15
hass CreditAttribution: hass commentedSee Google documentation linked in issue intro.
Comment #16
Simon Georges CreditAttribution: Simon Georges at Makina Corpus commentedIndeed:
Comment #17
hass CreditAttribution: hass commentedDamn. Thanks for pointing out!
Comment #18
hass CreditAttribution: hass commentedComment #20
hass CreditAttribution: hass commentedTheir docs have been wrong in past and are still. The
transport
need to be quoted or it is a JS variable.Comment #21
travelerttRemade the patch from #13 but with the {'transport': 'beacon'} changes from #20.
Comment #22
travelerttI found a mistake in the other patch. It was no longer sending eventLabel. Ignore my previous patch.
Comment #23
travelerttOne more time. Typo.
Comment #24
hass CreditAttribution: hass commentedNew patch with doubles quotes.
Comment #25
hass CreditAttribution: hass commentedThat patch is not like D8. Why have you not used page in the object?
Comment #27
hass CreditAttribution: hass commentedDamn. Now I see my fault. Fixed it in D8 and changed code style so this will not happen again hopefully as the ga object has named keys and this is easier to maintain. It also does not cause diff changes if we may add a new param later.
Comment #28
hass CreditAttribution: hass commentedComment #29
hass CreditAttribution: hass commentedLast patch has several bugs. Thanks to _nod.
Comment #32
hass CreditAttribution: hass commented