Using Piwik PRO Tag Manager to manage hundreds of Piwik installations

Published: June 1, 2016 Updated: August 24, 2018 Author Category Tag Manager, Use cases

Introduction

Let’s say that you are managing over a 100 websites and you want to start by implementing Piwik PRO tracking code and add other features and snippets later. Now let’s say that you can do achieve this almost automatically. Sounds interesting, doesn’t it?

Piwik PRO Tag Manager can help you to manage all these websites in one place within one dashboard – without hardly any IT assistance. The only help you’ll need is with the initial Piwik PRO Tag Manager code. But this is only a one time job – after that all other additional code which you may want to add to your website (along with conditions to activate them) can be added using the Piwik PRO Tag Manager dashboard.

But firstly you’ll want to configure the environment and set up your Piwik PRO analytics tool!

Piwik PRO Configuration

To configure Piwik PRO tracking using Piwik PRO Tag Manager, we first have to create a place for the data we will be collecting. Go to your Piwik PRO Administration page and click Add a new website:

Piwik PRO Administration Page

Now just name the new website and leave the URL field blank.

Free Comparison of 6 Enterprise-Ready Tag Management Systems

Get to know the 40 key differences between Google Tag Manager, Tealium, Segment, Adobe Marketing Cloud, Ensighten & Piwik PRO:

Download FREE Ebook

Piwik PRO Tag Manager Configuration – Piwik PRO main code

As we mentioned above, we have to put the Piwik PRO Tag Manager code into the source code of all our websites. But before doing that, it is necessary to create a container. And it is exactly this single container that all our websites will be using.

Now it is time for the first part of the configuration itself – implementing the Piwik code. To do this, we are going to use Piwik’s main code and a built-in variable. Go to your Piwik PRO Administration page and grab a Piwik PRO code. This will looks like this:


<script type="text/javascript">
var _paq = _paq || [];
_paq.push(["setDomains", "example.com"]);
_paq.push(['trackPageView']);
_paq.push(['enableLinkTracking']);
(function() {
var u="//piwik.example.com/";
_paq.push(['setTrackerUrl', u+'piwik.php']);
_paq.push(['setSiteId', 1]);
var d=document, g=d.createElement('script'), s=d.getElementsByTagName('script')[0];
g.type='text/javascript'; g.async=true; g.defer=true; g.src=u+'piwik.js'; s.parentNode.insertBefore(g,s);
})();
</script>
<noscript><p><img src="//piwik.example.com//piwik.php?idsite=1" style="border:0;" alt="" /></p></noscript>

The code above is only for a domain called example.com. But we have multiple domains you say. Yes and because of this, we are going to customize this code and make it even more dynamic.

Let’s change this bit:

...
_paq.push(["setDomains", "example.com"]);
...

to:

...
_paq.push(["setDomains", {{ Page Hostname }}]);
...

using a built-in Piwik PRO Tag Manager variable.

This modified code will be used to create a new tag called Piwik Tracking Code. Name the new tag (1), choose Asynchronous custom HTML tag (2) and paste the modified code into the Tag HTML field (3). By the way, this variable is available in the right-hand menu, as can be seen here:

Adding customized Piwik code into Piwik PRO Tag Manager
Adding customized Piwik code into Piwik PRO Tag Manager

Remember that on this screen we are using piwik.example.com as an example URL of the Piwik dashboard and 1 as a page ID. You will have to change it accordingly.

Now create a simple trigger which will allow you to fire your new tag on all the pages of all your websites.

Creating trigger for all pages of all websites
Creating trigger for all pages of all websites

Piwik PRO Tag Manager Configuration – Additional custom variables

Now we’re going to implement an additional functionality based on Piwik custom variable. Using this feature, we are going to send further information about the hostname of the page which user is visiting to Piwik. This information will be visible in the Visitor Log and can be used when custom segments.

To implement this additional custom variable, we need to create another tag called Piwik Hostname Variable (1). Again we choose a Asynchronous custom HTML tag (2) and paste the following code into the Tag HTML (3) field:

<script>
_paq.push(['setCustomVariable',1,"Hostname",{{ Page Hostname }},"visit"]);
_paq.push(['trackPageView']);
</script>

Adding Piwik custom variable code into Piwik PRO Tag Manager
Adding Piwik custom variable code into Piwik PRO Tag Manager

Using the same All pages trigger we saw above, save the whole configuration and publish changes by clicking the yellow Publish button.

Summary and further usage

If you have inserted Piwik PRO Tag Manager code into all your websites, you now have the ability to use Piwik PRO Tag Manager to implement tags globally. Here are a couple of tips for further usage:

  • Use Page hostname while configuring the trigger to distinguish a specific domain.
  • Use the {{ Page hostname }} variable in Javascript codes like we used in this use case.
  • Use regular expressions in trigger configuration to include a larger bunch of domains.
  • Remember that when using a trigger without conditions, the tag will be fired across all websites – great for new tools which will be used everywhere.

Free Comparison of 6 Enterprise-Ready Tag Management Systems

Get to know the 40 key differences between Google Tag Manager, Tealium, Segment, Adobe Marketing Cloud, Ensighten & Piwik PRO:

Download FREE Ebook

Tagged under

Author:

Szymon Grzesiak, Marketing Tech Lead

Tech savvy Performance Marketing Specialist. LinkedIn Profile

See more posts of this author
Free Comparison of 5 Enterprise-Ready Tag Management Systems

Share