Google Tag Manager example: Set promo code depending on prepayment
Please note that while our system is compatible with GTM integration, we do not offer specific configuration assistance as it is not a part of our standard offerings.
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: