Create a variable

Tag Manager

Needed permissions: owner, manage, edit & publish or edit

Video tutorial: watch on YouTube

A variable is used to store information that can be accessed by Tag Manager. For example, a variable page URL holds and passes information about the URL of the current page.

In Tag Manager, you can use ready-made variables, such as a page URL, page path, referrer, and more. Or, you can create your own variables.

In this article, we’ll show you how to create a variable.

Before you start

Here are some things to know before you start working with variables:

  • Variables can be used in tags and triggers.
  • You can create a variable in Tag Manager or via dataLayer push in JavaScript.
  • A variable created via dataLayer push can be used only in custom tags.
  • A variable is written as a text wrapped in double curly braces {{variable}}.
  • A variable is often used to store API keys to make them available for tags.
  • Variables are also used to capture and pass additional information from your website. For example, the name of the author of the blog post.

Create a variable

To create a variable, follow these steps:

  1. Go to Menu > Tag Manager.
  2. Navigate to Variables.
  3. Click Add new variable.
  4. Name the variable.
  5. Select the variable type.
    Create a variable in Tag Manager in Piwik PRO

    Tip: For more about variable types, read this article.

  6. In Variable settings, adjust settings. For example, in a DOM-element type add a CSS selector.
    Create a variable in Tag Manager in Piwik PRO
  7. When you’re done, click OK for the variable.
  8. After creating a variable, you’ll be able to select it from the list of variables in tags and triggers.

    Variable in a tag

    Create a variable in Tag Manager in Piwik PRO

    Variable in a custom tag

    Create a variable in Tag Manager in Piwik PRO

    Variable in a trigger

    Create a variable in Tag Manager in Piwik PRO

Was this article helpful?

Technical support

If you still have some questions, visit our community.
There’s always someone ready to help!

Back to help center