Support from Acquia helps fund testing for Drupal Acquia logo

Comments

hass’s picture

Issue summary: View changes
hass’s picture

hass’s picture

Title: Add 'useBeacon' to outbound events » Add 'useBeacon' to outbound links
hass’s picture

Status: Active » Needs review
FileSize
5.02 KB
albertski’s picture

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

hass’s picture

I'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...!?!??

albertski’s picture

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

hass’s picture

Chrome is piece of crap if it comes to Enterprise support.

chipk’s picture

Status: Needs review » Reviewed & tested by the community

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

hass’s picture

Title: Add 'useBeacon' to outbound links » Add 'useBeacon' for more reliable tracking with very fast browsers exiting before tracking code finishes

  • hass committed 31da7e8 on 8.x-2.x
    Issue #2355091 by hass: Add 'useBeacon' for more reliable tracking with...
hass’s picture

Version: 8.x-2.x-dev » 7.x-2.x-dev
Status: Reviewed & tested by the community » Patch (to be ported)
hass’s picture

Status: Patch (to be ported) » Needs review
FileSize
5.03 KB

Just a note how this functionality can verified. In network analysis the beacons become a POST request where it normally is a GET.

Simon Georges’s picture

Is 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 ;-)

hass’s picture

See Google documentation linked in issue intro.

Simon Georges’s picture

Indeed:

useBeacon : This option is now deprecated. Use 'transport' instead.

hass’s picture

Status: Needs review » Needs work

Damn. Thanks for pointing out!

hass’s picture

Title: Add 'useBeacon' for more reliable tracking with very fast browsers exiting before tracking code finishes » Add transport: 'beacon' for more reliable tracking with very fast browsers exiting before tracking code finishes

  • hass committed 63bcc36 on 8.x-2.x
    Issue #2355091 by hass: Add {transport: 'beacon'} for more reliable...
hass’s picture

Title: Add transport: 'beacon' for more reliable tracking with very fast browsers exiting before tracking code finishes » Add {'transport': 'beacon'} for more reliable tracking with very fast browsers exiting before tracking code finishes

Their docs have been wrong in past and are still. The transport need to be quoted or it is a JS variable.

travelertt’s picture

Remade the patch from #13 but with the {'transport': 'beacon'} changes from #20.

travelertt’s picture

Issue summary: View changes
FileSize
4.81 KB

I found a mistake in the other patch. It was no longer sending eventLabel. Ignore my previous patch.

travelertt’s picture

One more time. Typo.

hass’s picture

New patch with doubles quotes.

hass’s picture

Status: Needs review » Needs work

That patch is not like D8. Why have you not used page in the object?

  • hass committed 9e00974 on 8.x-2.x
    Issue #2355091 by hass: Change ga code style to object code style
    
hass’s picture

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

hass’s picture

Status: Needs work » Needs review
FileSize
8.24 KB
hass’s picture

Last patch has several bugs. Thanks to _nod.

  • hass committed 49a9a3e on 7.x-2.x
    Issue #2355091 by hass, travelertt: Add {'transport': 'beacon'} for more...

  • hass committed 911771a on
    Issue #2355091 by hass, travelertt: Add {'transport': 'beacon'} for more...
hass’s picture

Status: Needs review » Fixed

The last submitted patch, 4: Issue-2355091-Add-useBeacon-to-outbound-links.patch, failed testing.

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.