Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Switch links with onclick attribute to mousedown for Multidomain #69

Open
googleanalyticsresoneo opened this issue Mar 11, 2014 · 2 comments

Comments

@googleanalyticsresoneo
Copy link

By default we have
_gas.push(['_gasMultiDomain', 'click']);

But when one of the links already has a function binded to the 'onclick' gas should try to use 'mousedown' as an alternative handler so that, for example, the link isn't opened twice

I had the case with 'onclick' doing a window.open in JS in a new window and gas opening in the current window, resulting in 2 page views, one in a new visit and the other one in the current visit....

It shouldn't be needed to change the behavior for all the links in the page, but be careful to change the default behavior when it's at risk because an existing onclick code.

What do you think ?

@tomfuertes
Copy link
Contributor

Agree that this could be more gracefully handled but don't want to change as it would:

  1. cause lots of if statements/branches making the src/plugins/multidomain.js file unreadable
  2. more than likely be backwards incompatible for people upgrading
  3. negate the base use case for people who don't already have click handlers (which is much greater than the edge)

For now maybe we should just update the docs to make the standard _gasMultiDomain value mousedown instead of click? Happy to accept the PR.

@googleanalyticsresoneo
Copy link
Author

At least there should be more comments in the code or in the documentation on the benefits / risks of each methods
But it's very difficult to be sure that no link on a site is using an onclick handler, then having a safe solution would be way better. Source code being readable is a matter of comments and structure...shouldn't be an obstacle to stability and safety.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants