79479950

Date: 2025-03-03 00:25:43
Score: 0.5
Natty:
Report link

Shopify actually uses cookie discount_code. All you need to do is deploy the following script via GTM on all pages. It will grab discount url param and store it to discount_code cookie. Shopify will pick it up automatically.

    <script>
(function() {
    var params = new URLSearchParams(window.location.search);
    if (params.has('discount')) {
        var discountCode = params.get('discount');
        document.cookie = "discount_code=" + encodeURIComponent(discountCode) + "; path=/; max-age=" + (30*24*60*60);
    }
})();
</script>
Reasons:
  • Long answer (-0.5):
  • Has code block (-0.5):
  • Unregistered user (0.5):
  • Low reputation (1):
Posted by: Alex