Skip to content

Instantly share code, notes, and snippets.

@daniel-sim
Created April 7, 2021 10:26
Show Gist options
  • Save daniel-sim/1069666ffc6acbcf0f3bcda44ace9a9e to your computer and use it in GitHub Desktop.
Save daniel-sim/1069666ffc6acbcf0f3bcda44ace9a9e to your computer and use it in GitHub Desktop.
<script>
(function () {
var analytics = window.analytics
if (!analytics) return
var appInstallButton = document.querySelectorAll('.js-partner-tracking');
analytics.ready(function () {
ga('create', 'UA-REDACTED', 'auto', 'appTracker');
ga('appTracker.send', 'pageview');
if (appInstallButton.length) {
appInstallButton.addEventListener('click', ga('appTracker.send', 'event', 'Shopify App Store', 'Get App button', "REDACTED"))
}
})
})();
</script>
@daniel-sim
Copy link
Author

daniel-sim commented Apr 7, 2021

appInstallButton.addEventListener('click', ga('appTracker.send', 'event', 'Shopify App Store', 'Get App button', "REDACTED"))

This is where the bug is. addEventListenershould be passed a reference to a function. Right now, it's calling the function immediately.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment