Skip to main content

Event Tracking

Remember

Before sending any event ensure that the “install” has been successfully tracked. If an “install” is not recorded for the app on a device, Adtrace will receive and store your events, but they will NOT appear in the panel statistics.

Track an event

You can use Adtrace to track any event in your app. If you want to track every tap on a button, create a new event in the panel. Let's say that the event token is abc123. In your button's click handler method, add the following lines to track the click:

AdTraceEvent adtraceEvent = new AdTraceEvent("abc123");
AdTrace.trackEvent(adtraceEvent);

Track revenue

If your users generate revenue by engaging with advertisements or making in-app purchases, you can track this with events. For example: if one add tap is worth one Euro cent, you can track the revenue event like this:

AdTraceEvent adtraceEvent = new AdTraceEvent("abc123");
adtraceEvent.setRevenue(12000, "Toman");
AdTrace.trackEvent(adtraceEvent);

When you set a currency token, Adtrace will automatically convert the incoming revenues using the open exchange API into a reporting revenue of your choice.

If you want to track in-app purchases, please make sure to call trackEvent only if the purchase is finished and the item has been purchased. This is important in order to avoid tracking revenue your users did not actually generate.

Revenue deduplication

Add an optional transaction ID to avoid tracking duplicated revenues. The SDK remembers the last ten transaction IDs and skips revenue events with duplicate transaction IDs. This is especially useful for tracking in-app purchases.

AdTraceEvent adtraceEvent = new AdTraceEvent("abc123");

adtraceEvent.setRevenue(12000, "Toman");
adtraceEvent.setTransactionId("transactionId");

AdTrace.trackEvent(adtraceEvent);

Event parameters

In addition to the data points the Adtrace SDK collects by default, you can use the Adtrace SDK to track and add as many custom values as you need (user IDs, product IDs, etc.) to the event or session. Custom parameters are only available as raw data and will not appear in your Adtrace panel.

Use callback parameters for the values you collect for your own internal use, and partner parameters for those you share with external partners. If a value (e.g. product ID) is tracked both for internal use and external partner use, we recommend using both callback and partner parameters.

Event callback parameters

If you register a callback URL for events in your panel , we will send a GET request to that URL whenever the event is tracked. You can also put key-value pairs in an object and pass it to the trackEvent method. We will then append these parameters to your callback URL.

For example, if you've registered the URL http://www.example.com/callback, then you would track an event like this:

AdTraceEvent adtraceEvent = new AdTraceEvent("abc123");

adtraceEvent.addCallbackParameter("key", "value");
adtraceEvent.addCallbackParameter("foo", "bar");

AdTrace.trackEvent(adtraceEvent);

In this case we would track the event and send a request to:

http://www.example.com/callback?key=value&foo=bar

Adtrace supports a variety of placeholders, for example {idfa} for iOS or {gps_adid} for Android, which can be used as parameter values. Using this example, in the resulting callback we would replace the placeholder with the IDFA/ Google Play Services ID of the current device.

Remember

We don't store any of your custom parameters. We only append them to your callbacks. If you haven't registered a callback for an event, we will not read these parameters.

Event value parameters

You can send events with desired values. This works the same way as callback parameters; add them by calling the addEventParameter method on your AdTraceEvent instance.

AdTraceEvent adtraceEvent = new AdTraceEvent("abc123");

adtraceEvent.addValueParameter("key", "value");
adtraceEvent.addValueParameter("foo", "bar");

AdTrace.trackEvent(adtraceEvent);

Event callback identifier

You can add custom string identifiers to each event you want to track. We report this identifier in your event callbacks, letting you know which event was successfully tracked. Set the identifier by calling the setCallbackId method on your AdTraceEvent instance:

AdTraceEvent adtraceEvent = new AdTraceEvent("abc123");

adtraceEvent.setCallbackId("Your-Custom-Id");

AdTrace.trackEvent(adtraceEvent);