Validating Analytics Events
Validate events sent to Mobify analytics
Ensure that you are sending Mobify the right analytics events in the right format to take advantage of all the features offered in Mobify Analytics.
We have standardized event names and parameters in Mobify Analytics so that the events can be used for customer segmentation, reporting and benchmarking. It's important that the analytics events are named correctly and include the right expected parameters.
For instance, if we're recording pageviews for product pages, we wouldn't want pageviews recorded as 'pdp', 'product_page', 'product_details', etc. in different places, which would mean that it would become very difficult to query all pageviews across projects for product pages.
In order to define a canonical set of event names and other parameters, we use the Analytics Validator module in our analytics. The validator ensures that all events sent to Mobify Analytics are valid and use recognized event parameters.
How to use the Analytics Validator
Analytics validator is automatically set up once you create a new project in Mobify Cloud, and you don't need to do any additional work to set it up. The validator will only be invoked if you have enabled analytics tracking in your project settings in Mobify Cloud.
Once you start using the validator, you will be notified of any invalid events being sent to analytics via console messages during development. No error messages will be displayed once your project is published.
Google Analytics (and the Mobify Analytics backend) recognize the following commands:
- send: This sends an analytics event.
- set: This is used to set analytics key/value pairs, like custom dimensions.
- ecommerce:addTransaction: Used to send conversion data, usually from a checkout or confirmation page.
- ecommerce:addItem: Used to track addition of items to the cart, usually on the cart page.
send command, we recognize events that are present in the validator dictionaries.
The entities recognized by the validator are explained below:
- Categories: This dictionary stores the recognized event categories.
- Templates: This dictionary stores the recognized template (page) names.
Handling validator errors
A validator error will not prevent the data from being submitted to analytics. The validator will only warn you, allowing you to catch any accidental errors.
If you see an error during development, you would want to handle it according to the type of error:
- Unrecognized command: If you meant to use a command other than the recognized ones, ensure that this was intentional!
- Unrecognized category: It's possible that the category of event you want to track hasn't been seen in a project before. You might want to add it as described below. If it is a category specific to the project, you can ignore the error.
- Unrecognized template: Templates should always use one of the recognized names from the dictionary. If the template in question is uncommon, it's fine to ignore the error. If it's a template that is expected to be used in many projects, it would make sense to add it to the dictionary as described below.
Adding to the validator
If you think the validator needs to accept a new type of event, template name, etc., you can open an issue against the analytics validator repository to request the change. Remember that the addition should be one expected to be used commonly on other projects.Edit in GitHub