-
Notifications
You must be signed in to change notification settings - Fork 560
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Make outbound link/form logic configurable
- Loading branch information
1 parent
958ebeb
commit d7381da
Showing
8 changed files
with
166 additions
and
12 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
<!doctype html> | ||
<html> | ||
<body> | ||
<script> | ||
|
||
window.ga=window.ga||function(){(ga.q=ga.q||[]).push(arguments)};ga.l=+new Date; | ||
|
||
ga('create', 'UA-XXXXX-Y', 'auto'); | ||
|
||
// Note(philipwalton): | ||
// Selenium on Windows 10 Edge doesn't handle arrays well, so we fake it. | ||
var hitData = {count: 0}; | ||
ga('set', 'sendHitTask', function(model) { | ||
hitData[hitData.count] = { | ||
eventCategory: model.get('eventCategory'), | ||
eventAction: model.get('eventAction'), | ||
eventLabel: model.get('eventLabel'), | ||
devId: model.get('&did') | ||
}; | ||
hitData.count++; | ||
}); | ||
|
||
ga('require', 'outboundFormTracker', { | ||
shouldTrackOutboundForm: function(form) { | ||
var action = form.getAttribute('action'); | ||
return action.indexOf('google-analytics.com') < 0; | ||
} | ||
}); | ||
|
||
</script> | ||
|
||
<form action="http://google-analytics.com/collect"> | ||
<input id="submit-1" type="submit"> | ||
</form> | ||
|
||
<form action="/test/blank.html"> | ||
<input id="submit-2" type="submit"> | ||
</form> | ||
|
||
<script> | ||
document.addEventListener('submit', function(event) { | ||
if (window.__stopFormSubmitEvents__) { | ||
event.preventDefault(); | ||
} | ||
}); | ||
</script> | ||
|
||
<script async src='//www.google-analytics.com/analytics.js'></script> | ||
<script aysnc src="/autotrack.js"></script> | ||
|
||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
<!doctype html> | ||
<html> | ||
<body> | ||
<script> | ||
|
||
window.ga=window.ga||function(){(ga.q=ga.q||[]).push(arguments)};ga.l=+new Date; | ||
|
||
ga('create', 'UA-XXXXX-Y', 'auto'); | ||
|
||
// Note(philipwalton): | ||
// Selenium on Windows 10 Edge doesn't handle arrays well, so we fake it. | ||
var hitData = {count: 0}; | ||
ga('set', 'sendHitTask', function(model) { | ||
hitData[hitData.count] = { | ||
eventCategory: model.get('eventCategory'), | ||
eventAction: model.get('eventAction'), | ||
eventLabel: model.get('eventLabel'), | ||
devId: model.get('&did') | ||
}; | ||
hitData.count++; | ||
}); | ||
|
||
ga('require', 'outboundLinkTracker', { | ||
shouldTrackOutboundLink: function(link) { | ||
return link.hostname != 'google-analytics.com'; | ||
} | ||
}); | ||
|
||
</script> | ||
|
||
<a id="outbound-link" href="http://google-analytics.com/collect">Outbound</a> | ||
<a id="local-link" href="/test/blank.html">Local</a> | ||
|
||
<script> | ||
document.addEventListener('click', function(event) { | ||
if (window.__stopClickEvents__) { | ||
event.preventDefault(); | ||
} | ||
}); | ||
</script> | ||
|
||
<script async src='//www.google-analytics.com/analytics.js'></script> | ||
<script aysnc src="/autotrack.js"></script> | ||
|
||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters