Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save Webmasterei/8304d2fd095fa054119df26abbb1cff8 to your computer and use it in GitHub Desktop.
Save Webmasterei/8304d2fd095fa054119df26abbb1cff8 to your computer and use it in GitHub Desktop.
<script>
/*
Put this in a Matomo Tag Manager Container in order to copy each fresh event from the dataLayer to Matomo.
*/
window.dataLayer = window.dataLayer || [];
window._mtm = window._mtm || [];
var originalPush = dataLayer.push;
dataLayer.push = function() {
var args = Array.prototype.slice.call(arguments);
originalPush.apply(dataLayer, args);
var latestChange = args[args.length - 1];
window._mtm.push(latestChange);
};
</script>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment