Last active
November 15, 2022 15:15
-
-
Save seanberto/33d60933a6a79143dcc2add4c4db9dd4 to your computer and use it in GitHub Desktop.
An advanced attribution script that can be added to Additional Scripts in Shopify's Checkout Settings, to ensure traffic attribution for Accelerated Checkouts.
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
{% if first_time_accessed %} | |
<!-- Fueled Advanced Attribution Tracking Script --> | |
<script defer src="https://www.googletagmanager.com/gtag/js?id=[G_TARGET]"></script> | |
<script defer src="https://cdn-client.fueled.io/fueled-client-1.1.0.min.js"></script> | |
<script> | |
const fueledConfig = { | |
"analyticsWriteKey": "[ANALYTICS_WRITE_KEY]", | |
"frontendStorageUrl": "https://frontend-storage.fueled.io", | |
"datahubUrl": "https://datahub.fueled.io", | |
"settings": { | |
"gTarget": "[G_TARGET]" | |
} | |
}; | |
window.dataLayer = window.dataLayer || []; | |
function gtag() { | |
dataLayer.push(arguments); | |
} | |
gtag('js', new Date()); | |
gtag('config', fueledConfig.settings.gTarget); | |
window.addEventListener("fueled-ready", function () { | |
fueledClient.loadClient( | |
fueledConfig.datahubUrl, | |
fueledConfig.analyticsWriteKey, | |
fueledConfig.settings, | |
).then(() => fueledClient.setFrontendStorage( | |
fueledConfig.frontendStorageUrl, | |
Shopify.checkout.token, | |
)); | |
}); | |
</script> | |
{% endif %} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment