Skip to content

Instantly share code, notes, and snippets.

@boussouira
Last active May 2, 2021 11:12
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save boussouira/b805952f79a7c1a3fb050428d90501da to your computer and use it in GitHub Desktop.
Save boussouira/b805952f79a7c1a3fb050428d90501da to your computer and use it in GitHub Desktop.
Fire Facebook Pixel with for Free+Shipping Shopify Products
<script>
{% if first_time_accessed %}
var patchedTrack = function(type, data) {
data.revenue = "{{order.total_price | money_without_currency}}";
window.ShopifyAnalytics.lib.track2(type, data);
};
function patchTrack() {
if (window.ShopifyAnalytics &&
window.ShopifyAnalytics.lib &&
window.ShopifyAnalytics.lib.track != patchedTrack) {
if (typeof(window.ShopifyAnalytics.lib.track2) === 'undefined') {
window.ShopifyAnalytics.lib.track2 = window.ShopifyAnalytics.lib.track;
}
window.ShopifyAnalytics.lib.track = patchedTrack;
}
}
patchTrack();
setTimeout(patchTrack, 0);
document.patchInterval = setInterval(patchTrack , 100);
document.addEventListener("DOMContentLoaded", patchTrack);
{% endif %}
</script>
@jscore95
Copy link

jscore95 commented Mar 4, 2018

Thanks for the gist!

Do I include this snippet in my "Additional scripts" checkout page?

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