# LiveOps Campaigns

Source: https://tenjin.com/docs/liveops-campaigns/

## LiveOps Campaigns


The response from the LiveOps feature won’t always be real-time. We don’t have the guaranteed response time, so please implement the retry logic if you don’t get a response in time.


In Tenjin you can set up a custom user journey depending on their Attribution source. This opens up a whole array of different opportunities for better and more innovative in-app experience.


Example 1: Give in-game rewards to users that came from a specific ad campaign (eg cross-promotional campaign).


Example 2: Set different user flows (onboarding, monetization, and others) depending on whether a user is coming from an advertising campaign or from an organic source.


### How do LiveOps Campaigns work?


After Attribution data is processed on a Tenjin server, it can be returned to a client (app) upon request. The data is then processed by the app and used to display in-app content accordingly.


Tenjin is covering only the data transition part of this workflow. Dynamic replacement of in-app content is the responsibility of app developers.


### What Attribution data can I pass to an app?


When available, the following parameters can be passed back to an app:


| Parameter | Description | Example of returned value |
| --- | --- | --- |
| ` advertising_id ` | Advertising ID of the device | 11de7924d076456d9a203c8dee56632a |
| ` ad_network ` | Ad Network of the campaign | mintegral |
| ` campaign_id ` | Tenjin campaign ID | 6ebd3332-68f8-4919-875c-73fe6780d4f7 |
| ` campaign_name ` | Tenjin campaign name or campaign name from Ad Network (if the Ad Network passes campaign name to Tenjin via Attribution link or API, including all major channels: Meta, Google, Tiktok, Axon by Applovin, etc.) | mtg_us_1103 |
| ` site_id ` | Sub channel or source app id | mtg_1256527 |
| ` creative_name ` | Creative name from Ad Network | video_123 |
| ` remote_campaign_id ` | Ad Network campaign ID | ss_mtg_US_1123 |
| ` deferred_deeplink_url ` | Deferred Deep Link URL |  |
| ` click_id ` | Ad Network click ID | mtg65cebc77cddec80001c17f4w |
| ` analytics_installation_id ` | Tenjin generated application Install-specific identifier | f024e65f3dd94f16983726bcef192d68 |
| ` tenjin_parameter_0 ` to ` tenjin_parameter_5 ` | Custom pass-through values from your Tenjin tracking link (click URL) | summer_promo |


Here is the example of how the returned data object may look like:


JSON

```
{"referrer":"utm_source=(not%20set)&utm_medium=(not%20set)","referrer_params":{"utm_source":"(not set)","utm_medium":"(not set)"},"advertising_id":"00000000000000000000000000000000","ad_network":"ironsource","campaign_id":"f92aa3f1-8f2c-4110-ac2c-37c9a39618c4","campaign_name":"T1_ALL","site_id":"23445433","creative_name":"trees_playing_football"}
```


### What do I need to set up LiveOps campaigns with Tenjin?


You will need the following:


- Successfully integrate Tenjin SDK 1.12.19+

- Make sure you initiate Tenjin SDK in every app open

- For Android, main activity onResume, call instance.connect();

- For Unity Plugin, Application onStart and onApplicationPause, call instance.connect();


Integration Sample – iOS:


Objective-C

```
[[TenjinSDK sharedInstance]
    getAttributionInfo:^(NSMutableDictionary *attributionInfo) {
        NSLog(@"TenjinSDK getAttributionInfo result: %@", attributionInfo);
	  // Extract individual parameters
	  NSString *advertisingId = attributionInfo[@"advertising_id"];
	  NSString *adNetwork = attributionInfo[@"ad_network"];
	  NSString *campaignId = attributionInfo[@"campaign_id"];
	  NSString *campaignName = attributionInfo[@"campaign_name"];
	  NSString *siteId = attributionInfo[@"site_id"];
	  NSString *creativeName = attributionInfo[@"creative_name"];
	  NSString *deferredDeeplinkUrl = attributionInfo[@"deferred_deeplink_url"];
}]
;
```


Integration Sample – Android:


Java

```
import com.tenjin.android.Callback;
import com.tenjin.android.TenjinSDK;

public class TenjinDemo extends ActionBarActivity {
  //...other callbacks are here

  @Override
  public void onResume() {
    // standard code
    super.onResume()

    // Integrate TenjinSDK connect call
    String apiKey = "<API_KEY>";
    TenjinSDK instance = TenjinSDK.getInstance(this, apiKey);
    instance.connect();

    instance.getAttributionInfo(new Callback() {
      @Override
      public void onSuccess(Map<String, String> data) {
        if (data.containsKey(TenjinConsts.ATTR_PARAM_ADVERTISING_ID)) {
          // Advertising ID of the device
        }
        if (data.containsKey(TenjinConsts.ATTR_PARAM_AD_NETWORK)) {
          // Ad network of the campaign
        }
        if (data.containsKey(TenjinConsts.ATTR_PARAM_CAMPAIGN_ID)) {
          // Tenjin campaign ID
        }
        if (data.containsKey(TenjinConsts.ATTR_PARAM_CAMPAIGN_NAME)) {
          // Tenjin campaign name
        }
        if (data.containsKey(TenjinConsts.ATTR_PARAM_SITE_ID)) {
          // Tenjin site id
        }
        if (data.containsKey(TenjinConsts.ATTR_PARAM_CREATIVE_NAME)) {
          // Tenjin creative name
        }
      }
    });
  }
}
```


Integration Sample – Unity:


Objective-C

```
BaseTenjin instance = Tenjin.getInstance("<SDK_KEY>");

instance.GetAttributionInfo((Dictionary<string, string> attributionInfoData) => {
    // Extract individual parameters
    string advertisingId = GetValueOrDefault(attributionInfoData, "advertising_id");
    string adNetwork = GetValueOrDefault(attributionInfoData, "ad_network");
    string campaignId = GetValueOrDefault(attributionInfoData, "campaign_id");
    string campaignName = GetValueOrDefault(attributionInfoData, "campaign_name");
    string siteId = GetValueOrDefault(attributionInfoData, "site_id");
    string creativeName = GetValueOrDefault(attributionInfoData, "creative_name");
    string deferredDeeplinkUrl = GetValueOrDefault(attributionInfoData, "deferred_deeplink_url");
});
```
