Google Tag Manager example: Set promo code depending on prepayment

Storeganise does not offer support for GTM use or guarantee that any custom GTM code will work within Storeganise. Additionally, periodic updates to the Storeganise API could impact or even break how custom GTM code works. Please note also that many users may not see changes made via GTM due to the widespread use of ad-blockers.

Here's a Google Tag Manager tag example to automatically set a custom promo code based on how many prepaid months the customer chooses.

You'll first need to define promos in your admin app.

Then in your Google Tag manager dashboard, create a "Custom HTML" tag

<script>
var sp = new URLSearchParams(location.search);

if (sp.get('prepay') && !sp.get('code')) {
  var code;
  if (sp.get('prepay') >= 24) {
    code = 'prepay-2y';
  }
  else if (sp.get('prepay') >= 12) {
    code = 'prepay-1y';
  }
  else if (sp.get('prepay') >= 6) {
    code = 'prepay-6m';
  }

  history.pushState({}, null, location.pathname + location.search + '&code=' + code)
}
</script>

and 2 triggers:

Did this answer your question? Thanks for the feedback There was a problem submitting your feedback. Please try again later.

Still need help? Contact Us Contact Us