Hi Jovo Team,
after using Google Analytics for a longer time and building some bigger applications i find custom metrics and dimensions are both: biggest strength and biggest weakness. My proposal is to fix this by allowing to map them to certain indices and validate if all needed definitions are set.
Custom Definitions allow us to tell analytics new contents like:
- In which game is my user?
- How rank different games against each other?
- How often users are reaching a certain point in our flow?
There are many questions google Analytics can answer for specific voice platforms. For example Alexa is sending SessionEndedRequests containing valuable information why users are leaving a skill. Paired with the requests Google Analytics is sending, you can easily find out which states, intents (or other skill specific content) are producing the most max_reprompts for example. Therefore my last Pull Request enhanced Google Analytics with the feature to automatically track endReasons via customMetrics.
All the developer (after creating a new Google Analytics project ) has to do is creating five custom metrics in a specific order.
This works fine as long as you want to enhance analytics with new features like tracking unhandled counts. Assume a user project has the fix custom metrics mentioned above set to index 1 to 5. On index 6 and 7 are project specific metrics. This could be something like a user rank and money collected inside the game.
The new feature wants to track intents routed to unhandled on index 6. This would result in polluting the users rank statistic collected before. He would not even recognize it before his data is worthless. Therefore the approach used before would result in a plugin which is hard to enhance. Addiontionally when applications start to grow there could be limitations with the free contingent of custom definitions allowed in gAnalytics.
A developer should have options to choose which metrics and dimensions are tracked and assign them to a free slot.
I prepared a pull request to reach this. Inside the config metric and dimensions are mapped from their name to a target index via string, number tubles like here:
systemMetrics: [ ['Stop', 1], ['ERROR', 2], ['EXCEEDED_MAX_REPROMPTS', 3], ...
They are loaded into a map when the application starts. My suggestion would be to validate if each metric and dimension needed by the
jovo-analytics-googleAnalytics plugin is defined there and that there are no definitions mapped to the same index. If there is no index defined for the “Stop” metric for example the skill would prompt the user to insert it (or set it to 0 if it should not be tracked).
Although it would be possible to simply ignore not set definitions I prefer the approach above because it makes sure that tracking is not disabled due to typos or config mere issues.
What do you think @jan @Max @AlexSwe ? Should there be a config value to not validate system definitions?
One more questions is on the jovo$googleAnalytics object. This was set to the instance of the GoogleAnalytics Object before, which allowed developers to extend it without having to write a new interface and attach it to the jovo object. Now visible functions are manually set in the
setGoogleAnalyticsObject hook. What is the reason for this and how would you recommend to enhance the methods offered there (wouldn’t do access modifiers a similar job tho shadow properties?). @Max