Data layer event fires multiple times (different events)

Hi Piwik Pro community,

I have added a tag that fires when my custom event “GAEvent” shows and reads the specified data layer variables. But when looking through the debugger it seems that onward the user journey it will continue to fire the tag when loading new pages. And the tag fires for multiple events; both page views, custom events and multiple heartbeat pings.

In the attached picture, it is just for one users journey, but will the DLV variables (educations, faculty and studentYear) count 8 times for this specific user?

I just want it to fire once per user (session) but there isn’t multiplicity for data layer events, so i hope i can get a little clarification here.

Can you share your current setup? I guess the solution would be to use a custom code to:

  1. set event-level custom dimensions
  2. sent the custom event
  3. reset the event-level custom dimensions

The default behaviour keeps the custom dimensions set also for other events that are happening after the first one is sent.

Methods that would be useful here:

  • _paq.push(["setCustomDimensionValue", <ID>, <value>]);
  • _paq.push(["trackEvent", <category> <action>, <name>]);
  • _paq.push(["deleteCustomDimension", <ID>]);

As an alternative, you can also set the custom dimension via additional argument passed to the trackEvent method.

Full docs here: API — Piwik PRO Analytics Suite 16.40 documentation

Hi Kuba,

The current setup is as follows.

I made a tag that collects the custom dimensions i specified; DLV - studentYear, DLV - faculty and DLV - educations. And for the trigger i set it to trigger when it sees the data layer event “GAEvent”.

Tag

Trigger

But after taking a second look at custom dimensions, would i resolve the problem by using sessions dimensions rather than event dimensions? With the session dimension it add information about the session which is what i’m after?

Hi. Yes, that also solves your problem. Once the event is sent, a session-scoped dimension is set and it should be all fine. Going for session scope makes it also easier to use those values to do segmentation of data.

I tried going with the session dimensions and just need some clarification for a couple of questions.

Because it is a session dimension i should not expect it to show up under events? I see the “custom dimensions” in the lower left corner - is that correct?

And how long does a session last? Can I modify the timer myself?

Will the custom dimensions be bound to IP, visitor ID, cookie ID or something else? I’m thinking, so it will be easier to distinguish the amount of times per user has logged custom dimensions?

Yes, it’s correct, as it’s stored in the session scope. Session can last many hours, but it expires after 30 mins of inactivity (which means that no events have been sent for the last 30 mins). It cannot be adjusted at the moment.

Those values are stored in session scope as well, so generally yes. For instance, you should be able to get the no. of unique visitors that had a certain value set for given custom dimension.

Thanks Kuba, that was the exactly the help i needed :clap:

1 Like

Hi @kuba, just a quick follow up.

Is it possible to sort by cookie ID or make a report where that is possible? Or even other information from _pk_id cookie? I want to be able to distinguish already known/returning visitors i know have triggered the data layer variables from those who haven’t.

This way, to be able to have a report i for certain know are know visitors and another report where i don’t know if it is the same visitor who have triggered the data layer variables one or multiple times.

Cookie ID can be used in reporting as any other dimension. You can also create a segment which is checking if the custom dimension is set / not set. With segment applied, you can even browse a full session log to see for instance why the variables have not been triggered.