Analytics
The structure of an analytics event is comprised of a specified event name and an object providing additional event metadata. The metadata is based on the data structure that our third-party analytics platforms require, which includes the following properties:
category: referenced from a list of approved categories (it should not be created on the fly).
action: defines a specified item/element and describes the action that was taken upon it (e.g. "Button Clicked").
label: additional meta data about the action to help distinguish what it was (e.g. "Register", "Twitter" or "Email", to describe the "Button Clicked" action).
context: object containing all additional desired meta data around an event to help provide data around the full context of the event.
service: specify which third-party service to send the analytics data; defaults to all supported analytics platforms and typically not specified.
Triggering An Event
You can use the trackAnalyticsEvent()
helper function to trigger an analytics event from the JavaScript frontend in Phoenix.
Import the function, along with the EVENT_CATEGORIES
object, which contains a list of approved event categories that can be used to designate a category for the event.
Day To Day
As a developer, you should receive requests to add new analytics event triggers in a ticket, where it should specify all the relevant information to create an accurate event trigger:
name
category
action
label
context
service
(optional)
After adding an event trigger, you can test it in any of our environments by using the DS Debug console tool, which can be called in the browser console using the following command:
This will show logs when an analytics event is triggered and let you visualize the structure of the event that is sent to our analytics platforms, so you can confirm the structure is as intended.
Example analytics event console log with DS Debug console tool:
That's about it!
Last updated