Custom events allow you to track actions that don’t fall under standard events. This guide explains how to define, structure, and send custom events so they can be processed correctly by Admetrics.
What are Custom Events?
Unlike standard events, custom events let you track unique actions like newsletter subscriptions, experiment views, or custom leads.
Custom events are flexible, but they follow a defined format to ensure consistency and correct processing.
Important: Viewing Custom Events in Data Studio
For your custom events to appear and be usable in Data Studio, our system needs to be configured to recognize and process them specifically for reporting purposes. This involves us knowing the name
of your custom events and the data
keys you'll be sending.
Action Required for Data Studio Integration:
If you intend to analyze your custom events in Data Studio, please contact your account manager or our support team before implementing them, or as soon as you've defined them.
You will need to provide:
The exact
name
of each custom eventA list of all
data
keys and example values that will be included in thedata
object for each event
Without this prior communication and configuration on our side, your custom events will be collected but will not be available in Data Studio.
How to Send Custom Events
To send a custom event, you need to push it into the global admDataLayer
object. Here’s how:
Custom Event Structure
window.admDataLayer = window.admDataLayer || [];
window.admDataLayer.push({
type: String, // Optional — event type, defaults to 'custom'
name: String, // Required — event name
data: { // Required — attributes as key-value pairs
String: String,
// ... more key-value pairs
}
});
Explanation:
Field | Required | Description |
type | Optional | Defines the event type. Defaults to |
name | Required | The event name. Human-readable description of the event. |
data | Required | Attributes sent as key-value pairs. Both keys and values must be strings. |
Pre-defined Custom Event Examples
The following examples illustrate common custom events whose names and general data structures are already known to our system. If you use these event names and the typical data keys shown, they can generally be processed for Data Studio without requiring specific prior notification for these exact structures. For any new custom events or significant deviations, please refer to the "Important: Viewing Custom Events in Data Studio" section above.
1. Viewed Experiment
Track when a user views an experiment variation.
window.admDataLayer = window.admDataLayer || [];
window.admDataLayer.push({
name: 'Viewed experiment',
data: {
experimentId: '123456789',
experimentName: 'Experiment 1',
variationId: '987612345',
variationName: 'Variation 5'
}
});
2. Newsletter Subscribe
Track newsletter sign-ups.
window.admDataLayer = window.admDataLayer || [];
window.admDataLayer.push({
name: 'Newsletter subscribe',
data: {
email: '[email protected]'
}
});
3. Lead Generated
Track when a lead form is submitted.
window.admDataLayer = window.admDataLayer || [];
window.admDataLayer.push({
type: 'lead',
name: 'Lead generated',
data: {
email: '[email protected]',
form: 'Leadform1'
}
});
4. Checkout Events
Track checkout steps with minimal setup.
window.admDataLayer = window.admDataLayer || [];
window.admDataLayer.push({ name: 'Checkout started' });
window.admDataLayer.push({ name: 'Checkout contact info submitted' });
window.admDataLayer.push({ name: 'Checkout address info submitted' });
window.admDataLayer.push({ name: 'Checkout shipping info submitted' });