Client Setup
How to initialize the Angular SDK client and configure authentication
SDK Initialization
- Import the
AudienceLabService
in your Angular component or service. - Inject the service via the constructor.
- Call
initialize('YOUR_API_KEY')
in your component'sngOnInit
or service initialization logic.
constructor(private audienceLab: AudienceLabService) {}
async ngOnInit() {
await this.audienceLab.initialize('YOUR_API_KEY');
}
- The SDK will automatically fetch and cache a creative token.
- Retention metrics are sent automatically (only once per day).
API Key
- Obtain your API key from the AudienceLab dashboard.
- Replace
'YOUR_API_KEY'
with your actual key.
Automatic Features
- Creative Token Management: Handled automatically (fetch, cache, include in all events).
- Retention Events: Sent once per day, tracked via localStorage.
No additional configuration is required after initialization.