SdkReact sdk

API Reference

Audiencelab React SDK API reference

API Reference

initializeAudiencelab(apiKey: string): Promise<{ token: string, metrics: any }>

Initializes the Audiencelab SDK with your API key.

ParameterTypeDescription
apiKeystringYour API key for the Geeklab Audiencelab service

Returns a Promise that resolves to an object containing:

  • token: the generated session token
  • metrics: initial metrics data

sendCustomPurchaseEvent(id: string, name: string, value: number, currency: string, status: string, tr_id?: string): Promise<any>

Sends a custom purchase event.

ParameterTypeDescription
idstringThe ID of the purchased item
namestringThe name of the purchased item
valuenumberThe value of the purchase
currencystringThe currency code (e.g., "USD")
statusstringThe status of the purchase ("completed", "success", "failed")
tr_idstringOptional transaction ID for the purchase

Returns a Promise that resolves when the event is sent.


sendCustomAdEvent(adId: string, name: string, source: string, watchTime: number, reward: boolean, mediaSource: string, channel: string, value: number, currency: string): Promise<any>

Sends a custom ad event. Automatically tracks and includes total_ad_value (cumulative sum of all ad values) in the event payload.

ParameterTypeDescription
adIdstringThe ID of the ad
namestringThe name of the ad
sourcestringThe source of the ad
watchTimenumberWatch time in seconds
rewardbooleanWhether the ad was rewarded
mediaSourcestringThe media source (e.g., "admob")
channelstringThe channel (e.g., "paid")
valuenumberValue associated with the ad
currencystringCurrency code (e.g., "USD")

Returns a Promise that resolves when the event is sent.

The event payload automatically includes total_ad_value, representing the cumulative total of all ad values since app install. This value is stored using localStorage and persists across sessions.


sendCustomPurchaseEvent(id: string, name: string, value: number, currency: string, status: string, tr_id?: string): Promise<any>

Sends a custom purchase event. Automatically tracks and includes total_purchase_value (cumulative sum of all purchase values) in the event payload, but only increments when status is "completed" or "success".

ParameterTypeDescription
idstringThe ID of the purchased item
namestringThe name of the purchased item
valuenumberThe value of the purchase
currencystringThe currency code (e.g., "USD")
statusstringThe status of the purchase ("completed", "success", "failed")
tr_idstringOptional transaction ID for the purchase

Returns a Promise that resolves when the event is sent.

The event payload automatically includes total_purchase_value, representing the cumulative total of all purchase values since app install (only for completed/successful purchases). This value is stored using localStorage and persists across sessions.


sendCustomEvent(eventName: string, params: { value?: string; id?: string; [key: string]: string }): Promise<any>

Sends a custom event for tracking any user action or game event.

ParameterTypeDescription
eventNamestringA unique key or name that identifies this custom event (e.g., 'level_complete')
paramsobjectAn object containing additional parameters for the event

The params object can include:

  • value (optional): The main value associated with the event (e.g., score, amount, outcome)
  • id (optional): A unique identifier for the event, used for idempotency
  • Additional key-value pairs (optional, maximum of 2 allowed)

Returns a Promise that resolves when the event is sent.


getTotalAdValue(): Promise<number>

Retrieves the current cumulative ad value for the user.

Returns a Promise that resolves to a number representing the total value of all ads viewed by the user since app install.


getTotalPurchaseValue(): Promise<number>

Retrieves the current cumulative purchase value for the user.

Returns a Promise that resolves to a number representing the total value of all purchases made by the user since app install (only includes completed/successful purchases).