The Adjust SDK provides an AdjustEvent object which can be used to structure and send event information from your app to Adjust’s servers.
Instantiate an AdjustEvent object
public AdjustEvent(string eventToken);To send event information with the Adjust SDK, you need to instantiate an AdjustEvent object. This object contains variables that are sent to Adjust when an event occurs in your app.
To instantiate an event object, create a new AdjustEvent instance and pass the following parameters:
eventToken(string): Your Adjust event token.
var adjustEvent = new AdjustEvent("abc123");Adjust.TrackEvent(adjustEvent);Send an event
public static void TrackEvent(AdjustEvent adjustEvent);You can associate your Adjust event tokens to actions in your app to record them. To record an event:
- Create a new Adjust event instance and pass your event token as a string argument.
- Call the
TrackEventmethod with your event instance as an argument.
var adjustEvent = new AdjustEvent("abc123");Adjust.TrackEvent(adjustEvent);Example
This example shows how to record an event with the token g3mfiw whenever a user interacts with a button.
using AdjustSdk;using Windows.UI.Xaml;using Windows.UI.Xaml.Controls;
namespace AdjustWSExample{ public sealed partial class MainPage : Page { public MainPage() { this.InitializeComponent(); }
private void btnSimpleEvent_Click(object sender, RoutedEventArgs e) { var simpleEvent = new AdjustEvent("g3mfiw"); Adjust.TrackEvent(simpleEvent); } }}<Page x:Class="AdjustWSExample.MainPage" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:local="using:AdjustWSExample" xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" mc:Ignorable="d">
<Grid Background="{ThemeResource ApplicationPageBackgroundThemeBrush}"> <Button x:Name="btnSimpleEvent" Content="Record simple event" HorizontalAlignment="Left" Margin="10,0,0,0" VerticalAlignment="Top" Click="btnSimpleEvent_Click"/> </Grid></Page>Record event revenue
public void SetRevenue(double revenue, string currency);You can record revenue associated with an event by setting the revenue and currency properties on your event instance. Use this feature to record revenue-generating actions in your app.
To set these properties, call the SetRevenue method and pass the following arguments:
revenue(double): The amount of revenue generated by the eventcurrency(string): The ISO 4217 code of the event currency.
var adjustEvent = new AdjustEvent("abc123");adjustEvent.SetRevenue(0.01, "EUR");Adjust.TrackEvent(adjustEvent);Example
This example shows how to record an event with the token g3mfiw whenever a user interacts with a button. The function sets the revenue property of this event to 0.25 and the currency property to EUR.
using AdjustSdk;using Windows.UI.Xaml;using Windows.UI.Xaml.Controls;
namespace AdjustWSExample{ public sealed partial class MainPage : Page { public MainPage() { this.InitializeComponent(); }
private void btnRevenueEvent_Click(object sender, RoutedEventArgs e) { var revenueEvent = new AdjustEvent("g3mfiw"); revenueEvent.SetRevenue(0.25, "EUR") Adjust.TrackEvent(revenueEvent); } }}<Page x:Class="AdjustWSExample.MainPage" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:local="using:AdjustWSExample" xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" mc:Ignorable="d">
<Grid Background="{ThemeResource ApplicationPageBackgroundThemeBrush}"> <Button x:Name="btnRevenueEvent" Content="Record revenue event" HorizontalAlignment="Left" Margin="10,0,0,0" VerticalAlignment="Top" Click="btnRevenueEvent_Click"/> </Grid></Page>Deduplicate revenue events
public string PurchaseId { get; set; }You can pass an optional identifier to avoid recording duplicate events. The SDK stores the last ten identifiers and skips revenue events with duplicate purchase IDs.
To set the identifier, assign your purchase ID to the PurchaseId property on your event object.
AdjustEvent event = new AdjustEvent("abc123");
event.SetRevenue(0.01, "EUR");event.PurchaseId = "{PurchaseId}";
Adjust.trackEvent(event);Example
This example shows how to record an event with the token g3mfiw whenever a user interacts with a button. The function sets PurchaseId property to 5e85484b-1ebc-4141-aab7-25b869e54c49.
using AdjustSdk;using Windows.UI.Xaml;using Windows.UI.Xaml.Controls;
namespace AdjustWSExample{ public sealed partial class MainPage : Page { public MainPage() { this.InitializeComponent(); }
private void btnUniqueEvent_Click(object sender, RoutedEventArgs e) { var uniqueEvent = new AdjustEvent("g3mfiw"); var uniqueId = "5e85484b-1ebc-4141-aab7-25b869e54c49" uniqueEvent.PurchaseId = uniqueId Adjust.TrackEvent(uniqueEvent); } }}<Page x:Class="AdjustWSExample.MainPage" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:local="using:AdjustWSExample" xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" mc:Ignorable="d">
<Grid Background="{ThemeResource ApplicationPageBackgroundThemeBrush}"> <Button x:Name="btnUniqueEvent" Content="Record unique event" HorizontalAlignment="Left" Margin="10,0,0,0" VerticalAlignment="Top" Click="btnUniqueEvent_Click"/> </Grid></Page>Add callback parameters
public void AddCallbackParameter(string key, string value);If you register a callback URL in the Adjust dashboard, the SDK sends a GET request to your callback URL when it records an event.
You can configure callback parameters to send to your servers. Once you configure parameters on an event, the SDK appends them to your callback URL. You can use this information to analyze your users’ in-app behavior with your BI system.
Add callback parameters to your event by calling the addCallbackParameter method with string key-value arguments. You can add multiple parameters by calling this method multiple times.
var adjustEvent = new AdjustEvent("abc123");adjustEvent.AddCallbackParameter("key", "value");adjustEvent.AddCallbackParameter("foo", "bar");Adjust.TrackEvent(adjustEvent);The Adjust SDK measures the event and sends a request to your URL with the callback parameters. For example, if you register the URL https://www.mydomain.com/callback, your callback looks like this:
https://www.mydomain.com/callback?key=value&foo=barIf you’re using CSV uploads, make sure to add the parameters to your CSV definition.
Adjust supports many placeholders which you can use to pass information from the SDK to your URL. For example, the {idfa} placeholder for iOS and the {gps_adid} placeholder for Android. The {publisher_parameter} placeholder presents all callback parameters in a single string.
Example
This example shows how to record an event with the token g3mfiw whenever a user interacts with a button. The following callback parameters are added:
- The
event_token - The
revenue_amountgenerated by the event
The resulting callback URL looks like this:
http://www.mydomain.com/callback?event_token=g3mfiw&revenue_amount=0.05using AdjustSdk;using Windows.UI.Xaml;using Windows.UI.Xaml.Controls;
namespace AdjustWSExample{ public sealed partial class MainPage : Page { public MainPage() { this.InitializeComponent(); }
private void btnCallbackEvent_Click(object sender, RoutedEventArgs e) { var callbackEvent = new AdjustEvent("g3mfiw"); callbackEvent.AddCallbackParameter("event_token", "g3mfiw") callbackEvent.AddCallbackParameter("revenue_amount", "0.05") Adjust.TrackEvent(callbackEvent); } }}<Page x:Class="AdjustWSExample.MainPage" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:local="using:AdjustWSExample" xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" mc:Ignorable="d">
<Grid Background="{ThemeResource ApplicationPageBackgroundThemeBrush}"> <Button x:Name="btnCallbackEvent" Content="Record callback event" HorizontalAlignment="Left" Margin="10,0,0,0" VerticalAlignment="Top" Click="btnCallbackEvent_Click"/> </Grid></Page>Add partner parameters
public void AddPartnerParameter(string key, string value);You can send extra information to your network partners by adding partner parameters.
Adjust sends partner parameters to external partners you have set up. This information is useful for more granular analysis and retargeting purposes. Adjust’s servers forward these parameters once you have set them up and enabled them for a partner.
Add partner parameters to your event by calling the addPartnerParameter method with string key-value arguments. You can add multiple parameters by calling this method multiple times.
var adjustEvent = new AdjustEvent("abc123");adjustEvent.AddPartnerParameter("key", "value");adjustEvent.AddPartnerParameter("foo", "bar");Adjust.TrackEvent(adjustEvent);Example
This example shows how to record an event with the token g3mfiw whenever a user interacts with a button. The following partner parameters are added:
- The
product_idof the associated product - The
user_idof the user who triggered the event
using AdjustSdk;using Windows.UI.Xaml;using Windows.UI.Xaml.Controls;
namespace AdjustWSExample{ public sealed partial class MainPage : Page { public MainPage() { this.InitializeComponent(); }
private void btnPartnerEvent_Click(object sender, RoutedEventArgs e) { var partnerEvent = new AdjustEvent("g3mfiw"); partnerEvent.AddPartnerParameter("product_id", "29") partnerEvent.AddPartnerParameter("user_id", "835") Adjust.TrackEvent(partnerEvent); } }}<Page x:Class="AdjustWSExample.MainPage" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:local="using:AdjustWSExample" xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" mc:Ignorable="d">
<Grid Background="{ThemeResource ApplicationPageBackgroundThemeBrush}"> <Button x:Name="btnPartnerEvent" Content="Record partner event" HorizontalAlignment="Left" Margin="10,0,0,0" VerticalAlignment="Top" Click="btnPartnerEvent_Click"/> </Grid></Page>Add a callback identifier
public string CallbackId { get; set; }You can add a custom string identifier to each event you want to measure. Adjust’s servers can report on this identifier in event callbacks. This enables you to keep track of which events have been successfully measured.
Set up this identifier by assigning your identifier to the CallbackId property on your event object.
var adjustEvent = new AdjustEvent("abc123");adjustEvent.CallbackId = "Your-Custom-Id";Adjust.TrackEvent(adjustEvent);Example
This example shows how to record an event with the token g3mfiw whenever a user interacts with a button. In this example, the callbackId is set to f2e728d8-271b-49ab-80ea-27830a215147.
using AdjustSdk;using Windows.UI.Xaml;using Windows.UI.Xaml.Controls;
namespace AdjustWSExample{ public sealed partial class MainPage : Page { public MainPage() { this.InitializeComponent(); }
private void btnCustomEvent_Click(object sender, RoutedEventArgs e) { var customEvent = new AdjustEvent("g3mfiw"); customEvent.CallbackId = "f2e728d8-271b-49ab-80ea-27830a215147" Adjust.TrackEvent(customEvent); } }}<Page x:Class="AdjustWSExample.MainPage" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:local="using:AdjustWSExample" xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" mc:Ignorable="d">
<Grid Background="{ThemeResource ApplicationPageBackgroundThemeBrush}"> <Button x:Name="btnCustomEvent" Content="Record custom event" HorizontalAlignment="Left" Margin="10,0,0,0" VerticalAlignment="Top" Click="btnCustomEvent_Click"/> </Grid></Page>