About
A custom event is:
- an event that can not be categorized in other event type
- (generally speaking) a user interaction that can be measured independently from a web page or screen load.
Example
- video plays
Provider
Google Anaytics
- In a URL Get form. See in the hit builder
v=1 // Version.
&tid=UA-XXXXX-Y // Tracking ID / Property ID.
&cid=555 // Anonymous Client ID.
&t=event // Event hit type
&ec=video // Event Category. Required.
&ea=play // Event Action. Required.
&el=holiday // Event label.
&ev=300 // Event value.
v=1 // Version.
&tid=UA-XXXXX-Y // Tracking ID / Property ID.
&cid=555 // Anonymous Client ID.
&t=event // Event hit type.
&ec=UX // Event Category. Required.
&ea=click // Event Action. Required.
&el=Results // Event label.
&pa=click // Product action (click). Required.
&pal=Search%20Results // Product Action List.
&pr1id=P12345 // Product 1 ID. Either ID or name must be set.
&pr1nm=Android%20Warhol%20T-Shirt // Product 1 name. Either ID or name must be set.
&pr1ca=Apparel // Product 1 category.
&pr1br=Google // Product 1 brand.
&pr1va=Black // Product 1 variant.
&pr1ps=1 // Product 1 position.
- Video Play
ga('send', {
hitType: 'event',
eventCategory: 'Videos',
eventAction: 'play',
eventLabel: 'Fall Campaign'
});
- Outbound link and forms: Measuring outbound links and forms can be tricky because most browsers will stop executing JavaScript on the current page once a new page starts to load. See Beacon
function handleOutboundLinkClicks(event) {
ga('send', 'event', {
eventCategory: 'Outbound Link',
eventAction: 'click',
eventLabel: event.target.href,
transport: 'beacon'
});
}
Segment
In segment.io, a custom event is a called a track
Example of a track for a button.
analytics.track('Clicked CTA', {
location: 'header',
type: 'button'
});
- There will then be a table named clicked_cta which can be queried
SELECT COUNT(id)
FROM clicked_cta
- To get the users that clicked, just join to the identifies table, which contains user data, through the user_id foreign key.
SELECT DISTINCT i.name
FROM identifies i
JOIN clicked_cta cc ON cc.user_id = i.user_id;
MixPanel
window.mixpanel.track("Song Played", { // the event or action the user performed
name: "What Do You Mean", // specifics of the event
artist_name: "Gleeband"
album: "Purpose",
label: "Def Jam - School Boy",
genre: "Dance Pop"
});
Table Example
Segment
- The tracks table: A global table with all tracks
Column | Description |
---|---|
Anonymous_id | The anonymous ID of the user |
user_id | The unique ID of the user |
context_<key> | Non-user-related context fields sent with each page or screen call - Google Analytics - Browsing Context ( URL , screen, ) |
event | The slug of the event name, mapping to an event-specific table (without space) |
event_text | The name of the event (with space, …) |
id | An ID attached to the event at execution time and used for deduplication at the server level. |
received_at | When the page or screen call was received |
sent_at | When the page or screen call was triggered by the user |
- One Table by event name. The name of the table is the event column in the above table
Column | Description |
---|---|
Anonymous_id | The anonymous ID of the user |
user_id | The unique ID of the user |
context_<key> | Non-user-related context fields sent with each page or screen call - Google Analytics - Browsing Context ( URL , screen, ) |
event | The slug of the event name, so you can join the tracks table. |
event_text | The name of the event. |
id | The unique ID of the track call itself. |
received_at | When the page or screen call was received |
sent_at | When the page or screen call was triggered by the user |
<property> | Each property of your track calls is created as its own column, and the column type is automatically inferred from the data. |