Angular page change event
For activate() during page change for Angular SPA's, I saw in the Optimizely Angular code example the use of this Angular event:
There is a big group of devs who instead use (in terms of Google analytics)
Is there an advantage to using $locationChangeSuccess to trigger active()?
Here's a StackOverflow for $viewContentLoaded:
Solved! Go to Solution.
From the Optimizely perspective, it's all about triggering your experiment to activate at the right time (and possibly over and over again) using the activate() function that Optimizely passes in (when using the function type of conditional activation).
We chose to use the $locationChangeSuccess event in the developer example because it was pretty clear what that event might mean. $viewContentLoaded is one angular event and $locationChangeSuccess is another, the former being particular to the view being updated (but not necessarily the route) while the other is particular to the actual route (and possibly not the view).
It's up to the site developer to know which event is better to trigger the particular experiment that needs activating based on how the site is rendered and updated. This could very likely be different than the event that makes sense to send a "pageview" to Google Analytics.
Hope this helps!