Variables Use Cases

In Piwik Pro Marketing Suite you can use predefined Variables as well as create your own. Variables it’s a set of the most often used pieces of website information (e.g. domain, specific page element ID, social media account id etc.). This is a solution that helps defining a set of rules based on your website’s configuration. For more details about Variables please check this article.

Piwik Pro Tag Manager currently supports the following Variables:

  • Custom JavaScript (for example you can detect a mobile browser and get True/False value, and based on that create a trigger; for example show this banner if ‘mobile browser’ is false)
  • You can use the code below to detect whether it’s mobile browser or not:

    function() {
     if( /Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent) ) 
     return 'true';
     return 'false';

    And then if you want to trigger a specific tag for mobile browsers all you need to do is add a condition and use your Variable.

  • Constant – you can write a constant element, for example, some ID or account number.
    Constant string Variables are commonly used when there might be multiple tags that leverage the same account number.
  • Cookie – you can choose a cookie name and then use it as a trigger.

  • -If you use Authentication on your website then you can extend User ID tracking to return users without them needing to authenticate. This can be done with a cookie.
    -You can save the number of visits in the cookie and then e.g fire different tag for first time and x time visitor.

  • Data Layer – you can choose everything that is included in Data Layer, some JS events for example (we can look at them in the preview -> events log).
  • So if you have in Data Layer e.g value of the order on e-commerce site. You can trigger the tag only if the order total equals to or is higher than the desired amount.

  • DOM element – all the elements on the website that have IDs; you can either pull the value or just yes/no response.
  • You can use this to access any arbitrary DOM element on the page. This becomes useful if you want to fire an event only if a certain element is on the page.

  • Document -when an HTML document is loaded into a web browser, it becomes a document object. Here you can check all the full list.
  • For example activeElement returns the currently focused element in the document so based on the element that is returned you can trigger a specific tag.

  • URL – it is very useful when it comes to accessing components of the current page URL (default) or of any URL string returned by a Variable.
  • It may be used to get more details about your sales. If you have additionals parameters added to your URL address (e.g when the item is sold). You can use the URL Variable to get those parameters and then based on those perform a further action or trigger a tag.

    Let’s say the URL address looks like that
    Where recid (recipient ID) and deliid (delivery ID) is attributed to each sale.

    Then after creating the Variables for each ID, we can use these Variables and Custom Dimensions to have the additional metric to track the sales. All you need to do is create a Custom Dimension based on Variable {{recid}} and {{delid}}

    Was this article helpful?

    Be the first to rate this article.

    Technical Support

    If you have any questions, drop us a line at

    We’re happy to help!