Tag fired only on 2nd page refresh

So when I’m in debug mode my custom dimensions don’t fire, but when I refresh the page the custom dimensions fire. Logically, a user is not supposed to refresh the page every time he goes to a new url!
Can you help me ?
Thank you

Can you share your current setup or link to the website where it’s implemented? I assume that your problem is that the custom dimensions are set only on the 2nd page view? There might be multiple reasons and to be able to debug we need access to exact setup.

The website is as follows: https://epsilon-france.com/
As you can see it’s custom dimensions

Here you have an example of a tag created.

And here the trigger condition :

Hope this can help you find the problem.
If you have any other needs, please let me know.

And how is the PageName variable defined? In general, most likely during the first page view, the tracking library loads before the variable value is set. This way, it’s not sent to the analytics module since trigger conditions are not met.

Since this dimensions is to be added always, have you considered setting it directly in the default Piwik PRO tag?

Attached is an overview of the variable.

I cannot set the custom dimensions on the default Piwik Pro since the trigger conditions are not the same.

There is no solution for this problem?
Should we opt for another TMS?
Thanks for your feedback.

Where do you initialize the datalayer variable? Most likely it’s a standard concurrency issue. Datalayer might be defined too late, meaning that the first tracking request is done before it’s defined.