Event tracking

Send event


To send an event, use Tracker.send(Event) method, which in the most basic scenario looks like this:

Method name: Tracker.send(event)

Declaration

public static void send(Event event)

Parameters

Parameter Type Mandatory Default Description
event Event yes - Event object (e.g. CustomEvent() instance).

Return Value

Void type method.

Example

Tracker.send(new CustomEvent("my.action", "My label that will be visible on Activity Stream"));

However, you can pass additional parameters with the event, like in the example below:

TrackerParams params = new TrackerParams.Builder()
                .add("name", "John")
                .add("surname", "Rise")
                .add("company", "Synerise")
                .add("age", 25)
                .add("isGreat", true)
                .add("lastOrder", 384.28)
                .add("count", 0x7fffffffffffffffL)
                .add("someObject", new MySerializableObject())
                .build();
Tracker.send(new CustomEvent("my.action", "My label that will be visible on Activity Stream", params));

The Tracker caches and enqueues all your events locally, so they will all be sent eventually.
It also supports Android O’s Background Execution Limits.

For more information about events, check Event Tracking.

Flush events from Tracker


The flush method forces the sending of events from the queue to the server. This method is a global operation and does not require authorization.

Method name: Tracker.flush()

Declaration

public static void flush()

Parameters

No parameters required.

Return Value

Void type method.

Example

Tracker.flush();

Set customIdentifier for events


You can pass your custom identifier to match your customers in the database. Your custom identifier will be sent in every event, in the event params.

Method name: Tracker.setCustomIdentifier(customIdentifier)

Declaration

public static void setCustomIdentifier(String customIdentifier)

Parameters

Parameter Type Mandatory Default Description
customIdentifier String yes - Client’s custom identifier

Return Value

Void type method.

Example

Tracker.setCustomIdentifier(customIdentifier)

Set customEmail for events


You can pass your custom email to match your customers in the database. Your custom email will be sent in every event, in the event params.

Method name: Tracker.setCustomEmail(customEmail)

Declaration

public static void setCustomEmail(String customEmail)

Parameters

Parameter Type Mandatory Default Description
customEmail String yes - Customer’s email

Return Value

Void type method.

Example

private void setCustomEmail(String customEmail) {
    Tracker.setCustomEmail(customEmail);
}

Get events for client


Retrieve events for the client.

Method name: Client.getEvents(clientEventsQuery)

Declaration

public static IDataApiCall<List<ClientEventData>> getEvents(ClientEventsQuery clientEventsQuery)

Parameters

Parameter Type Mandatory Default Description
clientEventsQuery ClientEventsQuery yes - Object to create clientEvent query

Return Value

IDataApiCall<List<ClientEventData» object to execute the request.

Example

private IDataApiCall<List<ClientEventData>> getEventClientsCall;
    if (getEventClientsCall != null) getEventClientsCall.cancel();
    getEventClientsCall = Client.getEvents(clientEventsQuery);
    getEventClientsCall.execute(({ this.onSuccess() }), ({ this.onFailure() });
😕

We are sorry to hear that

Thank you for helping improve out documentation. If you need help or have any questions, please consider contacting support.

😉

Awesome!

Thank you for helping improve out documentation. If you need help or have any questions, please consider contacting support.

Close modal icon Placeholder alt for modal to satisfy link checker