Best Practices regarding clearing of variable persistence in PP TM

Imagine a link click tracking scenario.
With a link click, I want to track the Event Target Element Text into a Custom Dimension in PP Analytics.

With the click event, I write the Event Target Element Text to a Data Layer Variable {{ DL - Element Target Text }}. The Variable is mapped to PP Analytics Custom Dimension 1.

Right after the click, an automatic scroll Event happens. Now, Custom Dimension 1 is again set to the earlier element text, even though it has nothing to do with the scroll event anymore.

This is a very common problem in TMS’s working with recursive-merge-style data layers.

In GTM, I can work around it by using the “Data Layer Version 1” (=> takes the value only if it is part of the current Data Layer Event payload).

In Tealium, there is no persistence unless I force it, so this problem does not exist.

In Adobe Launch, if you use the adobeDataLayer, you can differentiate persistence and non-persistence by putting everything that should not persist into the eventInfo property of the Data Layer Event.

But how do I handle this without ugly Custom Code workarounds or additional fake undefined pushes in PiwikPro?

Additionally, PiwikPro Analytics seems to have its own auto-persistence. So even if I clear the data layer variable that feeds the TM Variable “Element Text” by setting it to undefined, PP Analytics still sets CD 1 to the text with every ensuing event unless I clear it. Is there a “clearVars” method similar to Adobe Analytics or a setting “do not persist” that makes sure nothing persists unless explicitly declared? I find something like that much cleaner and less likely to cause accidental tracking errors. I remember this discussion: Clear Variables after request / Avoid automatic persistence of Custom Dimensions etc. into next Hit - #2 by anthonybartczak But I still hope there is a more elegant way by now.

Hi @loldenburg,

When it comes to tag templates - there is no built-in switch to remove a value from the JavaScript Tracking Client after it has been sent with a specific event. It will be deleted upon a page reload or if you call deleteCustomDimension.

You can call deleteCustomDimension to delete a value of a specific custom dimension (or do a simple loop to delete multiple values).

Probably the most reliable way if you want to achieve this is doing something like this (yep, custom HTML tag):

var _paq = _paq || [];
_paq.push(["setCustomDimensionValue", 3, "value"]);
_paq.push(["trackEvent", "video", "video-paused", "intro.mp4", 15.2]);
_paq.push(["deleteCustomDimension", 3]);

When it comes to custom events (and some other events that support dimensions (object)) you can add an object of custom dimensions that will “attach” them only to this specific tracking request (it basically skips setting the value in JSTC)

API — Piwik PRO Analytics Suite 18.7 documentation

There’s also the method that uses tag priority.

Thanks. That’s just very unsatisfying that for these kinds of widespread needs (I have not had a tracking project where sth like this wasn’t needed), you need to work around with custom code.

You answered the Custom Dimension part, but what about Data Layer Variable reset? Is the only way an additional dataLayer.push({"myVar": undefined}) after each event?

Yes, as of now this is the only way.

Thanks. I think this is quite a big issue, especially since PP fires all kinds of its own native data layer events and in many cases, variable values persist into these events even if I don’t want to.
A TMS must be clear and easy in how it persists variable values and how it clears them. GTM is not a great example here unfortunately, but at least they have Data Layer version 1 (no persistence) and DL V 2 (recursive-merge persistence) which make it possible to never persist anything that you don’t want to persist.

Hey Lukas, I’ve seen you around here a bit and you seem like a Piwik power user and pretty knowledgeable. I can’t assist with anything here but I just wanted to share some thoughts and see if you maybe agree.

Personally, I made the choice not to use the Piwik TMS after some preliminary testing showed the debug mode a bit meh, it seemed a bit unpolished, and it lacked tag scheduling - another essential feature for avoiding TMS hacking. It felt like a tool that reached 80% of the way, but not all the way, so I stuck with GTM to avoid more unknown pitfalls I felt certain I would encounter.

I feel this is a recurring problem with Piwiks suite of products and I’m a bit afraid their strategy of being a full service suite is spreading them a bit thin, especially after moving into the CDP space which likely takes a lot of their development resources due to copious integrations. I bet this strategy pays off when working with large enterprise clients who want to completely move their stack to a European provider, but I feel it deprioritises power users like us.

I still recommend Piwik, but if another company provided a similar analytics service which allowed more fine-grained session/user segmentation opportunities while staying true to the web analytics philosophy, I’d start recommending that instead. In my opinion the current broad feature base but unpolished depth leaves Piwiks “full service” strategy a bit weak for the power user segment and vulnerable to disruption from specialised competitors. However, from a business perspective this prioritisation may make more sense considering big enterprise contracts is a great place to be.

Just my 2c. Any thoughts about this yourself?

1 Like

Hi Alex,
thanks a lot for your 2 cents, I am sure Piwik Pro appreciates those, too (you have to change them into grosze first, though).

“Personally, I made the choice not to use the Piwik TMS”

=> I made the same choice for my first PP client who already was on GTM (see From Google Analytics to Piwik Pro? A Real Client Case 2/2 | by Lukas Oldenburg | The Bounce ). For this different client, I had to use PP TM because this is a reimplementation of a completely messed up setup. The current implementation has allowed me to dive deeper into PP TM and there are plenty of things that are not optimal there. I would go with GTM any day over PP TM if I can. That being said, you can get a basic setup to work with Piwik TM as well. I am compiling a list of things I am missing in PP TM, maybe I will write an article about it when I find time.

In terms of Analytics, I still prefer PP Analytics over GA for most use cases, it is a much more solid product (or GA4 is maybe simply not a solid product, still, compared to GTM).

I feel this is a recurring problem with Piwiks suite of products and I’m a bit afraid their strategy of being a full service suite is spreading them a bit thin, especially after moving into the CDP space which likely takes a lot of their development resources due to copious integrations. I bet this strategy pays off when working with large enterprise clients who want to completely move their stack to a European provider, but I feel it deprioritises power users like us

=> I have thought the exact same thing. While it is courageous to try to manage a TMS, an Analytics tool, a CMP and a CDP (if you can really call Piwik’s CDP a CDP), it is a giant spread for a smaller company like PP. I am not a business expert, but I would probably not try to compete in the TMS and CDP market and focus all my resources on improving the Analytics product and maybe the CMP. But it is of course easy to say this from the outside, I am sure the smart guys at PP have thought about this as well, and they know much better what they are doing and why…

But maybe @piotr wants to share his point of view on this?

1 Like

Hey guys,

Our core focus remains on the analytics part (if we’re not delivering here, please let us know!). We’re building smaller products that integrate tightly with it to provide a unique feature set, rather than blatantly trying to just chase GA. We’ll probably never build a better standalone TMS than Google, although some companies will choose a suite of products, including the Piwik PRO TMS, simply because of how well it integrates with other products.

We’re ~165 people and about half of that is product, which is an unusually high ratio of engineers for a SaaS company. If we put all those engineers on one module, we’re not going to be 4x faster with development there.

Could we be more successful as a “pure analytics” company? If you look at the history of acquisitions in the market, the enquiries from prospects and customers over the years, my answer is ‘I don’t think so’. But our advisor, Brian Clifton, shares your view. And I hear you all. I won’t promise a much better standalone TMS, but definitely a better analytics platform. Thanks for your 2 grosze.



Hey Piotr,

Thanks for the reply.

I agree with Lukas, Piwik is better than GA4. And in a lot of aspects, better than GA UA as well. It’s a great product, and then you throw the privacy and European hosting on top of it and it’s a slam dunk. It’s also great to see European analytics companies growing and competing, not only in the local market, but outside of it too. Rooting for you guys. That’s also why I’m writing this, because I legitimately care about seeing you guys succeed.

I got started with Piwik in October 2022, which admittedly isn’t that long, but I’ve gotten pretty deep into it, used it a lot myself, and have first-hand seen how other experienced analysts with decades of experience use it as well. And personally, I feel like you guys are missing potential by not catering to the more experienced analyst audience. Most of the changes to the analytics module has been bug fixes/minor tweaks, QoL improvements (session timeouts, multiple accounts on one email), the Data Studio integration improvement, and the e-commerce module which has been great to see. The kind of stuff that when prioritised by a framework like ICE it gets done as a lot of users are affected by it, and it’s reasonably straight-forward to implement.

But I wish there was a bit more development velocity in more advanced analysis features that realistically only 5-20% of analysts will use, but the people who are able to ask those questions, and get answers to them, create massively outsized business impact. I get variations of the same question at least once a month from the analysts I work with. It’s always a variation of: how can I segment sessions by events in a session. “How can I see the effect of users who visited a certain page”. “What’s the conversion rate decrease when users encounter errors in the booking system, and which errors should we prioritise fixing?”. “How can I only include users who engaged with feature X in this analysis, and not everyone else”. Or “How can we analyse this A/B test in Piwik”.

The same question that has been raised multiple times on these forums.

And even the same question that Lukas asked himself this summer.

And the answer has been “it’s not possible”. Or “We can hack it with a custom session dimension, but it has these caveats and is not backwards compatible”.

I’m not saying that this is what’s happening, but I think it’s easy to assume to that users are generally worth the same and it’s better to develop features that most users will encounter. I’m making the case that the business value Piwik provides is dependent on the analyst, and spending some development time on serving the seasoned analysts who really dig deep into your tools and granularly into the data can really change Piwik from a “Choose Piwik, it’s the best we have at the moment” into “Choose Piwik, it’s totally worth it”.

I think I wrote my previous comment about spreading yourself a bit thin as that’s been my explanation for why most development in the analysis module has stuck to the “easy” and “necessary” stuff. But I really wish you guys would tackle some of the harder stuff. Like more advanced segments, comparing more than 2 segments, custom metrics, re-thinking the customizability of the report section, or reworking the organization of the custom reports section in the analysis module so that it can scale past small teams. The kind of stuff that isn’t a selling point for your sales team, but the features that day to day let the best analysts make outsized impacts on their organizations.

I’m mostly referring to the analytics module here, as that is in our case ultimately the reason we chose to use Piwik. Not the TMS, CDP or CMP.

And sorry for hijacking your thread Lukas, but I just noticed the same pattern here.

Cheers guys, here’s to a great 2024 :partying_face:


Hey Alex,
Thanks for sharing your journey. Much appreciated and I loved the read :smiley:
I won’t promise anything, I’ll just make sure that THE person for analytics module sees the feedback: @Jarek :slight_smile:

Happy 2024 to you too!

1 Like

Thank you gentleman for your very insightful feedback. It’s a great read that helps me to look at the product from power users’ perspective. I’m aware of many pain points you mentioned and considering that while shaping the roadmap for the upcoming months/quarters.
At this point, I can’t guarantee what and when will be done so make sure you’re up to date with a changelog.
I hope that we will have an opportunity to meet in person and dig deeper into your needs.

1 Like