I’m trying to track views on a page where the conditions may change (public view, private view, preview view) but the URL does not (in the case of preview the query changes, but not the path). I’d like to track views to this page uniquely based on the conditions. I’ve tried using setPageViewName to add “/public”, etc, to the path each time addPageAction is called, but I’m not seeing any modified URLs in the Browser pageview view. I’ve added “public” “private” and “preview” to the Segment Allow List, but I’m not seeing anything but “…/*” where I would expect the modified path to be. Is this something that can be done?
That combination of API calls doesn’t sound like it’s going to achieve what you’re trying to do.
setPageViewName() specifically targets the
browserTransactionName attribute on your PageView event data, and those are only recorded when a page load occurs. On top of that, once the event has been reported (just after window load) we don’t have a way to retroactively change that.
addPageAction() generates a completely custom event, PageAction, which are harvested on a 30 second cycle. If you’re trying to record user activity that’s not a page load or route change, this is certainly a valid way to go about it, but using
setPageViewName() with it won’t have any effect on either the PageAction event you’re creating or the existing PageView events you’ve already reported.
I think you could try creating a PageAction event that you can use to track the number of times someone changes the views, and just report the
private/etc. state as a custom attribute. There are a couple of different ways to go about it.
The example listed here shows an example of the call being used to create a new PageAction event with a custom attribute:
This would create a new PageAction event with
name = userSignup and custom attribute
You can also assign custom attributes to both PageAction and PageView data using the
setCustomAttribute API call. Here again though, just using this call won’t generate a new event for you or modify existing ones, it will only provide some additional options for decorating the events your application is reporting with additional information.
Hope this helps!