Angular
Learn how to track your first visit & event using Angular.
Pre-Requisites
Before proceeding, ensure you:
Have installed Angular
Get started here
Get your project ID
Sign up on Litlyx Dashboard and create a new project.
1. Install
Choose your package manager & install the library.
2. Import
Now import Litlyx in your entry-point
file. The easiest way in Angular is in the file app.component.ts
.
import { Lit } from "litlyx-js"
app.module.ts
.3. Initialize
Next, initialize the Litlyx library with your project in your entry-point file (always app.component.ts
in this example) as follow:
constructor() {
Lit.init("your_project_id");
}
This line will already collect more than 10 KPIs for you such as Page Visits
, Referrers
, Countries
, Unique Sessions
and many more.
4. Collect Custom Events
To customize your experience, add the following line in each function you desire. There is no limit to the number of events.
If you want to test if it works and everything is well configured, import the OnInit method in the entry-point file (always app.component.ts
in this example):
export class AppComponent implements OnInit {
and implement the imported function as follows:
ngOnInit(): void {
Lit.event("your_event_name");
}
If you want to exercise more control over your events, you can use the metadata
field.
ngOnInit(): void {
Lit.event("your_event_name", metadata: {
'type': 'INIT_LIBRARY',
'priority': 0.9
});
}
In your dashboard, you can group them in the Events
tab with the Event Metadata Analyzer
.