Event tracking
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.
You can use Adtrace to track all kinds of events. Let's say you want to track every tap on a button.
Simply create a new event token in your panel. Let's say that event token is abc123.
You can add the following line in your button’s click handler method to track the click:
var adtraceEvent = new AdTraceEvent("abc123");
AdTrace.trackEvent(adtraceEvent);
Revenue tracking
If your users can generate revenue by tapping on advertisements or making In-App Purchases, then you can track those revenues with events. Let's say a tap is worth €0.01. You could track the revenue event like this:
var adtraceEvent = new AdTraceEvent("abc123");
adtraceEvent.setRevenue(2000, "Toman");
AdTrace.trackEvent(adtraceEvent);
Callback parameters
You can also register a callback URL for that event in your panel and we will send a GET request to that URL whenever the event gets tracked. In that case you can also put some key-value pairs in an object and pass it to the trackEvent method. We will then append these named parameters to your callback URL.
For example, suppose you have registered the URL https://www.adtrace.io/callback for your event with event token abc123 and execute the following lines:
var adtraceEvent = new AdTraceEvent("abc123");
adtraceEvent.addCallbackParameter("key", "value");
adtraceEvent.addCallbackParameter("foo", "bar");
AdTrace.trackEvent(adtraceEvent);
In that case we would track the event and send a request to:
https://www.adtrace.io/callback?key=value&foo=bar
It should be mentioned that we support a variety of placeholders like {idfa} for iOS or {gps_adid} for Android that can be used as parameter values. In the resulting callback the {idfa} placeholder would be replaced with the ID for Advertisers of the current device for iOS and the {gps_adid} would be replaced with the Google Advertising ID of the current device for Android. Also note that we don't store any of your custom parameters, but only append them to your callbacks. If you haven't registered a callback for an event, these parameters won't even be read.
You can read more about using URL callbacks, including a full list of available values, in our callbacks.
Both parameters in this method must be strings. If either of the passed parameters is not a string, the key-value pair will not be added to the parameters list.
Event Parameters
Similarly to the callback parameters mentioned above, you can also add parameters that Adtrace will transmit to the adtrace backend of your choice. You can export these values in the panel.
This works similarly to the callback parameters mentioned above, but can be added by calling the addEventParameter method on your AdTraceEvent instance.
var adtraceEvent = new AdTraceEvent("abc123");
adtraceEvent.addEventParameter("key", "value");
adtraceEvent.addEventParameter("foo", "bar");
AdTrace.trackEvent(adtraceEvent);
Both parameters in this method must be strings. If either of the passed parameters is not a string, the key-value pair will not be added to the parameters list.
Callback identifier
You can also add custom string identifier to each event you want to track. This identifier will later be reported in event success and/or event failure callbacks to enable you to keep track on which event was successfully tracked or not. You can set this identifier by calling the setCallbackId method on your AdTraceEvent instance:
var adtraceEvent = new AdTraceEvent("abc123");
adtraceEvent.setCallbackId("Your-Custom-Id");
AdTrace.trackEvent(adtraceEvent);