Math variable helps you perform basic mathematical operations between two values. It’s particularly useful when working with dynamic values such as calculating percentages, applying formulas, or adjusting numeric values based on other variables.
The initial development of this template was done by Lars Friis, and it is now maintained by Stape.
This variable offers a simple configuration where you can:
Before implementation, make sure you have set up server Google Tag Manager container. |
1. Download Math variable from GitHub or get it from the Template Gallery.
2. Import the variable to server Google Tag Manager by clicking Templates → New Variable Template.
Click three dots in the top right corner → Click import → Add template that you’ve recently downloaded → Click Save.
3. Select the operation you want to perform (Multiply, Divide, Add, or Subtract).
For Value 1 and Value 2, you can either enter static values or reference other variables by clicking on the icon.
Click Save.
4. Once the variable is set up, you can reference it in your tags (e.g., Google Ads conversion tracking, analytics, etc.). Simply use the Math Variable in the relevant field of the tag configuration.
You can easily perform real-time calculations based on dynamic values within the GTM environment, without needing to implement external scripts. Math variable is to the rescue :) If you need help with your Stape account, please don’t hesitate to leave a ticket.
Stape has lots of tags for server GTM! Click on Try for free to register and check them all.