This page lists all the events available in the module-data-analyticstracker. More details about the events and their schemas can be found on our Notion page.
Identifies the user
When should I call identify?
type Identify = {
id: string;
type?: 'administrator' | 'assessor' | 'author' | 'editor' | 'instructor' | 'learner' | 'manager' | 'support' | 'user';
organisationId?: string;
isInternal?: boolean;
content?: {
packageId?: string;
packageTitle?: string;
method?: string;
methodId?: string;
edition?: string;
targetYear?: string;
businessUnit?: string;
productType?: string;
grade?: string;
schoolType?: string;
discipline?: string;
semanticVersion?: string;
};
};
tracker.identify({
id: 'my-user-id',
type: 'instructor',
organisationId: 'my-guid',
cultureInfo: 'xx-YY',
isInternal: true,
content: {
packageId: 'pkg123',
packageTitle: 'Math 101',
method: 'online',
methodId: 'method123',
edition: '2nd',
targetYear: '2024',
businessUnit: 'education',
productType: 'course',
grade: '10',
schoolType: 'high-school',
discipline: 'mathematics',
semanticVersion: '1.0.0',
},
});
Track a page view
type Page = {
category: string;
subCategory?: string;
type: string;
id?: string;
brand?: { name?: string };
pageName?: string;
};
type Referrer = {
module?: string;
label?: string;
itemId?: string;
elementId?: string;
};
tracker.page({
category: 'content',
subCategory: 'learning-content'
type: 'quiz',
id: 'my-quiz-id',
brand: { name: 'nectar' },
pageName : 'my pagename'
})
Page type and category must be kebab-case and must on the list of approved page types and categories. Find them here:
If right before the page
event a referrer
event is tracked, referrer data will be added to the event.
import { createTracker } from '@infinitaslearning/module-data-analyticstracker';
const tracker = createTracker({ ...trackerOptions });
tracker.referrer({
module: 'main-menu',
label: 'Do a quiz',
itemId: 'quiz',
});
For the referrer event it is recommended to use attributes based tracking.
<button title="Take me to the quiz" data-mdat="referrer" data-mdat-module="my-amazing-button" />
All custom events have the following fields to specify where they occured in the dom:
type BaseFields = {
module?: string; // kebab-case, identifies the section of the page where the event occured
itemId?: string; // kebab-case, identifies the item on which the event occured
elementId?: string; // kebab-case, identifies the (html) element on which the event occured
frameCorrelationId?: string; // kebab-case, identifies the frame in which the event occured
};
Link with target outside of the platform
type ExitLink = {
url: string;
label?: string;
};
Available actions:
tracker.exitLinkClicked({
url: 'https://www.infinitaslearning.com',
label: 'Go to infinitas',
module: 'main-menu',
itemId: 'infinitas-link',
});
Link with target outside of the platform
type File = {
name?: string;
id?: string;
source?: string;
extension?: string;
url: string;
};
Available actions:
tracker.fileDownloaded({
url: 'https://www.infinitaslearning.com',
name: 'Answerbook',
id: '123abc',
source: 'edify',
extension: 'pdf',
});
It is recommended to use automatic tracking using data attributes for external links.
Use the navigated
event when navigating. The tracker will figure out whether it's a referrer
, exitLinkClicked
or fileDownloaded
event. All of the attributes of the before mentioned events can be used in the navigated
event. Only url
is required. This event is useful when the type of navigation is not known, eg. in a shared component.
tracker.navigated({
url: 'https://www.infinitaslearning.com',
label: 'Go to infinitas',
module: 'shared-menu',
itemId: 'infinitas-link',
});
type FormSubmited = {
fornName: string; // Name of the form
formId: string; // The ID of the form. Normally this is the formsbuilder ID.
product?: ProductEntity;
};
type FormClicked = {
fornName: string; // Name of the form
formId: string; // The ID of the form. Normally this is the formsbuilder ID.
clickText: string; // In the context of forms, the term "clickText" could refer to the label or text associated with a clickable element
product?: ProductEntity;
};
Available actions:
tracker.formSubmitted({
id: 'form-66',
name: 'Zichtzending Getal & Ruimte JR',
});
Any type of frame opened on top of the page. Events that occure within the frame can be related to the frame by providing the frame-correlation-id
.
type Frame = {
type: string;
id?: string;
frameType: 'widget' | 'confirmation' | 'pop-up';
};
Available actions:
When a frame is opened on a page. Consider using the page
event instead if the frame covers the entire page.
const frame = await tracker.frameOpened({
type: 'calculator',
id: 'home-page-calulator-widget',
frameType: 'widget',
});
The frame-opened
event generates a new frame-correlation-id
, which can be used the correlate all events that happen on the frame.
When used with attribute based tracking, it's also possible for the platform to provide the frame-correlation-id
. In that case make sure to update the value when the frame is closed, so a next frameOpened
and consequetive events inside the frame can be properly correlated.
When a frame is closed
type ClosedFrame = Frame & {
result: 'confirmed' | 'rejected' | 'cancelled';
frameCorrelationId: string; // optional for most, but required in this event
};
const closedFrame: ClosedFrame = {
...frame!, // Includes the frame-correlation-id
result: 'cancelled',
};
tracker.frameClosed(closedFrame);
When a frame is moved
type MovedFrame = Frame & {
locationX?: number; // int
locationY?: number; // int
frameCorrelationId: string; // kebab-case optional for most, but required in this event
};
const movedFrame: MovedFrame = {
...frame!, // Includes the frame-correlation-id
locationX: 400,
locationY: 500,
tracker.frameMoved(movedFrame);
};
List of items. Often used to for display or filtering/searching
type ItemList = {
type: string;
count?: number; // int
pageSize?: number; // int
pageNumber?: number; // int
displayMode?: string;
order?: {
field?: string;
direction?: 'asc' | 'desc';
};
};
Available actions:
Use displayed
when item list is displayed and filtering and/or searching is not applicable
const itemList: ItemList = {
type: 'books',
count: 58,
pageSize: 20,
pageNumber: 3,
displayMode: 'grid-view',
};
tracker.itemListDisplayed(itemList);
Use filtered
when item list is searched and/or filtered
type FilteredItemList = ItemList & {
searchTerm?: string;
facets?: Record<string, (string | number | boolean | Date)[]>;
};
const filteredItemList: FilteredItemList = {
type: 'books',
count: 58,
pageSize: 20,
pageNumber: 3,
displayMode: 'grid-view',
order: {
field: 'title',
direction: 'asc',
},
facets: {
subject: ['english', 'biology'],
'target-year': ['1', '2'],
},
};
tracker.itemListFiltered(filteredItemList);
Use ordered
when item list is ordered
type ItemListOrdered = ItemList & {
parentId?: string | undefined;
parentDescription?: string | undefined;
items: {
id: string;
description?: string | undefined;
sequence?: number | undefined;
}[];
};
const orderdedItemList = {
type: 'content-manage',
parentId: '7a4d1e53-852e-4a7b-9f93-96f3c7e7e1c6',
parentDescription: 'The Midnight Serenade',
items: [
{
id: 'aebab1b3-5c43-47a6-8f25-638eaf2a314f',
description: 'The Enigma of Shadows',
sequence: 1,
},
{
id: faker.string.uuid(),
description: 'Echoes from the Forgotten Past',
sequence: 2,
},
],
};
tracker.itemListOrdered(orderdedItemList);
Feedback from a teacher about the learning result of their student(s)
type LearningFeedback = {
id: string;
};
Available actions:
type LearningFeedbackCreated = {
to: string[];
subject: {
type: 'content-unit';
id: string;
score?: number;
attemptNumber: number;
};
};
tracker.learningFeedbackCreated({
id: '123',
to: ['stud-1', 'stud-2'],
subject: {
type: 'content-unit',
id: 'abc',
score: 55,
attemptNumber: 1,
},
});
type LearningFeedbackMessageSent = {
to: string[];
messageId?: string;
subject: {
type: 'content-unit';
id: string;
score?: number;
attemptNumber: number;
};
};
tracker.learningFeedbackMessageSent({
id: '123',
messageId: '123',
to: ['stud-1', 'stud-2'],
subject: {
type: 'content-unit',
id: 'abc',
score: 70,
attemptNumber: 1,
},
});
tracker.learningFeedbackRead({ id: '123' });
tracker.learningFeedbackMessageDeleted({ id: '123', messageId: '123' });
Element. Use whenever there is no better semantic event.
type Element = {
type?: string;
value?: string;
};
Available actions:
Use when the element has been clicked.
tracker.elementClicked({
elementId: 'example-checkbox',
type: 'checkbox',
value: 'true',
module: 'task-planner',
itemId: 'add-content-unit',
});
Experiment. Use whenever there is an A/B test or other experiment running.
type Experiment = {
experimentName: string;
experimentGroup: 'control' | 'variant';
};
Available actions:
tracker.experimentStarted({
experimentName: 'my-experiment',
experimentGroup: 'control',
});
When you track events with attributes e.g. data-mdat="element-clicked"
. If you're also navigating you might want to submit the current url to track the right page. You can do that by setting data-mdat-url={window.location.href}
. This is not needed if you don't change the url.