matomo-org / matomo

Empowering People Ethically with the leading open source alternative to Google Analytics that gives you full control over your data. Matomo lets you easily collect data from websites & apps and visualise this data and extract insights. Privacy is built-in. Liberating Web Analytics. Star us on Github? +1. And we love Pull Requests!
https://matomo.org/
GNU General Public License v3.0
19.91k stars 2.65k forks source link

Track landing page with custom dimension #16146

Open tipmaster opened 7 years ago

tipmaster commented 7 years ago

I am trying to figure out how I can set the custom dimension field only for a landing page and not override it on subsequent requests; is this possible to do with javascript? Can I check if the value is set conditionally in JS?

tsteur commented 7 years ago

and not override it on subsequent requests

Maybe custom dimensions in scope visit help?

tipmaster commented 7 years ago

We are using custom dimensions with the scope "visit".

However, from the documentation:

Custom Dimensions in scope “Visit” can be sent along any tracking request and are stored in the visit of a specific visitor. If you set different values for a given dimension during the lifetime of a visit, the last value set will be used. A typical example could be any device information or the version of the app the visitor is using.

So our question is how can we use javascript to ensure the value is only set once when the visit starts?

tsteur commented 7 years ago

Got it. You would probably need to set a cookie or something once you set the custom dimension the first time and then make sure it won't be overwritten anymore. However, this may be bit tricky since you won't know when it is a new visit. Eg visitor might visit website and you set custom dimension and cookie. Visitor comes back 40 minutes later => Piwik creates new visit, you would need to set the custom dimension again but the cookie you set would likely prevent this since you cannot know when Piwik creates a new visit.

To solve this, a custom Piwik plugin would be likely needed.

tipmaster commented 7 years ago

Thank you.

To confirm there is no way for me to use the Javascript SDK to either

or is there?

tsteur commented 7 years ago

Exactly