Skip to content

Instantly share code, notes, and snippets.

@vlastv
Created March 15, 2017 14:07
Show Gist options
  • Save vlastv/ce99d79a0097e17271f954d555ee383a to your computer and use it in GitHub Desktop.
Save vlastv/ce99d79a0097e17271f954d555ee383a to your computer and use it in GitHub Desktop.
Duplicate all Google Analytics hits
<script>
(function (window, variable, task) {
window['GoogleAnalyticsObject'] = variable;
window[variable] = window[variable] || function () {
(window[variable].q = window[variable].q || []).push(arguments);
if (arguments[0] === "create") {
window[variable]((arguments[2] && arguments[2].name || "t0") + ".require", "duplicator");
}
};
window[variable].l = 1 * new Date();
window[variable]("provide", "duplicator", function (tracker, options) {
var xhr = new XMLHttpRequest(),
handler = tracker.get(task);
tracker.set(task, function (model) {
handler(model);
xhr.open("GET", "/collect?" + model.get("hitPayload"), true);
xhr.send();
})
});
})(window, 'ga', 'buildHitTask');
</script>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment