Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ability to reset custom dimension when tracking SPA with Matomo Tag Manager #368

Open
peterbo opened this issue Oct 8, 2021 · 5 comments
Labels
Enhancement New feature or request

Comments

@peterbo
Copy link
Contributor

peterbo commented Oct 8, 2021

For tracking with the legacy tracking code, there is _paq.push(['deleteCustomDimension', 1]); - that doesn't work with the Tag Manager. That results in custom dimensions being tracked for pageviews and actions that should not contain this data.

@tsteur
Copy link
Member

tsteur commented Oct 11, 2021

@peterbo would this be fixed by #201 maybe? I think there was some discussion in #201 (comment)

Or how do you reckon would this work best?

@peterbo
Copy link
Contributor Author

peterbo commented Oct 11, 2021

Hey @tsteur - #201 would definitely help to get rid of tons of workarounds. But in this case, it would not solve the problem. As an example, the following use-case:

  • An SPA, sending us an event "virtualPageView" with some variables, e.g. "topic_name", "course_name", etc.
  • These variables should be set as action custom dimensions
  • "topic_name" and "course_name" do not exist for every "virtualPageView", but on a following "virtualPageView", the variables are tracked as action custom dimensions.

Possible solutions:

  • (re)Set these variables as "null" in the datalayer, when there are no values to provide - but this would introduce some kind of "logic" to the datalayer, that increases maintenance complexity (because a full list of variables has to be present at any time and place within the CMS)
  • delete variable values before tracking a pageview - this is tricky, because when exactly is the right moment to do this?
  • At the moment, I'm getting the last "virtualPageView" event in a Tag MatomoTagManager.dataLayer.getAllEvents(); and search for all variables that have been set. The rest will be resettet to null.

Also, I'm not quite sure how to solve this the most elegant way. Perhaps a setting like "reset variable value if not present in the next event of the same type" or something like this. But this seems to be a bit too "specific". ;)

@tsteur
Copy link
Member

tsteur commented Oct 12, 2021

I wonder if in that case maybe somehow needs to be hooked into this using Custom HTML tag and calling _paq.push() directly?

I would have suggested to maybe have an option to delete custom dimensions after the page view or after the event was tracked. But if I understand things correctly that wouldn't help in that case?

@peterbo
Copy link
Contributor Author

peterbo commented Oct 13, 2021

I tried to execute _paq.push(['deleteCustomDimension', 1]); in a custom HTML tag, but this had no effect. Sorry, I should have explained that a bit better.

I would have suggested to maybe have an option to delete custom dimensions after the page view
Mostly, variables for SPA are set with an event. (e.g. event: virtualPageview, section: test, page_type: test, business_unit: test, etc) - perhaps an option would be great to have an option for events to reset one or more variables, when it gets triggered. With this function, we could "imitate" a "real" context changing pageView. Two settings would be necessary for that

  • in an event, there could be a checkbox: "Reset certain variables on trigger"
  • in each variable there could be a checkbox: "Reset this variable if certain event gets triggered"

Or simply have one setting for an event to imitade a context changing pageView -> all variables get reset, before some get reassigned.

When this specific event gets triggered, all the selected variables get resetted, before the new variables sent with the event get assigned. I'm not sure how practical this would be, but for SPA, this certainly would help.

@tsteur tsteur added the Enhancement New feature or request label Oct 14, 2021
@tsteur tsteur added this to the Priority Backlog milestone Oct 14, 2021
@tsteur
Copy link
Member

tsteur commented Oct 14, 2021

Got it 👍
it almost goes into the concept of interactive vs non-interactive events or so maybe. But that's again a different story.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants