> ## Documentation Index
> Fetch the complete documentation index at: https://documentation.qonversion.io/llms.txt
> Use this file to discover all available pages before exploring further.

# Analytics Mode

> Implement subscription analytics in 20 minutes without changing your existing in-app purchases flow.

Analytics (Observer) mode allows you to get the best-in-class analytics in minutes. You can also use [real-time subscriptions events](integrations-overview#tracked-events) in third-party integrations, webhooks, and get accurate Apple Search Ads attribution using this mode. You don't need to change your current in-app purchases flow.

After you install the SDK, follow the steps below.

## 1. Launch SDK

Initialize the SDK:

<CodeGroup>
  ```swift Swift theme={null}
  import Qonversion

  func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {
      let config = Qonversion.Configuration(projectKey: "projectKey", launchMode: .analytics)
      Qonversion.initWithConfig(config)
    	return true
  }
  ```

  ```objectivec Objective-C theme={null}
  #import "Qonversion.h"
    
  - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
      QONConfiguration *configuration = [[QONConfiguration alloc] initWithProjectKey:@"projectKey" launchMode:QONLaunchModeAnalytics];
      [Qonversion initWithConfig:configuration];
      
      return YES;
  }
  ```

  ```java Java theme={null}
  import com.qonversion.android.sdk.Qonversion;
  import com.qonversion.android.sdk.QonversionConfig;
  import com.qonversion.android.sdk.dto.QLaunchMode;

  public class App extends Application {
      @Override
      public void onCreate() {
          super.onCreate();
          final QonversionConfig qonversionConfig = new QonversionConfig.Builder(
                  this,
                  "projectKey",
                  QLaunchMode.Analytics
          ).build();
          Qonversion.initialize(qonversionConfig);
      }
  }
  ```

  ```kotlin Kotlin theme={null}
  import com.qonversion.android.sdk.Qonversion
  import com.qonversion.android.sdk.QonversionConfig
  import com.qonversion.android.sdk.dto.QLaunchMode

  public class App : Application {
      override fun onCreate() {
          super.onCreate()
          val qonversionConfig = QonversionConfig.Builder(
              this,
              "projectKey",
              QLaunchMode.Analytics
          ).build()
          Qonversion.initialize(qonversionConfig)
      }
  }
  ```

  ```dart Flutter theme={null}
  import 'package:qonversion_flutter/qonversion_flutter.dart';

  final config = new QonversionConfigBuilder(
    'projectKey',
    QLaunchMode.analytics
  ).build();
  Qonversion.initialize(config);
  ```

  ```typescript React Native theme={null}
  import Qonversion, {
    QonversionConfigBuilder,
    LaunchMode,
  } from '@qonversion/react-native-sdk';

  const config = new QonversionConfigBuilder(
    'projectKey',
    LaunchMode.ANALYTICS
  ).build();
  Qonversion.initialize(config);
  ```

  ```csharp Unity theme={null}
  using QonversionUnity;

  private void Start()
  {
      QonversionConfig config = new QonversionConfigBuilder(
              "projectKey",
              LaunchMode.Analytics
          ).Build();
      Qonversion.Initialize(config);
  }
  ```

  ```typescript Cordova theme={null}
  const config = new Qonversion.ConfigBuilder(
    'projectKey',
    Qonversion.LaunchMode.ANALYTICS,
  ).build();
  Qonversion.initialize(config);
  ```

  ```typescript Capacitor theme={null}
  import Qonversion, {
    QonversionConfigBuilder,
    LaunchMode,
  } from '@qonversion/capacitor-plugin';

  const config = new QonversionConfigBuilder(
    'projectKey',
    LaunchMode.ANALYTICS
  ).build();
  Qonversion.initialize(config);
  ```
</CodeGroup>

**→[Get your Qonversion Project Key](quickstart#2-create-a-project-and-register-your-app)**

## 2. Sync Purchases

### iOS, StoreKit 2

#### Subscriptions only

In case you're using StoreKit Version 1, we automatically handle all the needed data about transactions that occurred. However, in the case of StoreKit Version 2, it is necessary to leverage the`syncStoreKit2Purchases()` SDK method. Call this function every time you receive a successful purchase result or auto-renewed transaction.

<CodeGroup>
  ```swift Swift theme={null}
  // In case you're using CocoaPods:
  QonversionSwift.shared.syncStoreKit2Purchases()

  // In case you're using Swift Package Manager:
  import QonversionSwift

  QonversionSwift.shared.syncStoreKit2Purchases()
  ```

  ```objectivec Objective-C theme={null}
  [[Qonversion sharedInstance] syncStoreKit2Purchases];
  ```

  ```dart Flutter theme={null}
  Qonversion.getSharedInstance().syncStoreKit2Purchases();
  ```

  ```typescript React Native theme={null}
  Qonversion.getSharedInstance().syncStoreKit2Purchases();
  ```

  ```csharp Unity theme={null}
  Qonversion.GetSharedInstance().SyncStoreKit2Purchases();
  ```

  ```typescript Cordova theme={null}
  Qonversion.getSharedInstance().syncStoreKit2Purchases();
  ```

  ```typescript Capacitor theme={null}
  Qonversion.getSharedInstance().syncStoreKit2Purchases();
  ```
</CodeGroup>

#### Subscriptions & Consumables

In case you're using StoreKit Version 2 and selling Subscriptions and Consumables we recommend using **one** of these methods **before finishing transactions**:

<CodeGroup>
  ```swift Swift theme={null}
  await QonversionSwift.shared.syncStoreKit2Transactions()

  await QonversionSwift.shared.handleTransaction(transaction)

  await QonversionSwift.shared.handleTransactions(transactions)
  ```
</CodeGroup>

### Android

1. Check whether you have set your products up correctly. Make your GooglePlay subscriptions backwards compatible to have the best possible accuracy in Qonversion. [Learn more here](android-in-app-products)

2. While you are using Qonversion SDKs in Analytics Mode, in-app purchases implementation is entirely on your side. Remember to consume and acknowledge purchases to attribute them to users. **Otherwise, the purchases will be automatically refunded in 3 days.** See the official Android Developer documentation for [processing purchase details](https://developer.android.com/google/play/billing/integrate#process).

3. Sync data with Qonversion in your current purchase flow. Call `syncPurchases()` after every purchase.

<CodeGroup>
  ```java Java theme={null}
  Qonversion.getSharedInstance().syncPurchases();
  ```

  ```kotlin Kotlin theme={null}
  Qonversion.shared.syncPurchases()
  ```

  ```dart Flutter theme={null}
  Qonversion.getSharedInstance().syncPurchases();
  ```

  ```typescript React Native theme={null}
  Qonversion.getSharedInstance().syncPurchases();
  ```

  ```csharp Unity theme={null}
  Qonversion.GetSharedInstance().SyncPurchases();
  ```

  ```typescript Cordova theme={null}
  Qonversion.getSharedInstance().syncPurchases();
  ```

  ```typescript Capacitor theme={null}
  Qonversion.getSharedInstance().syncPurchases();
  ```
</CodeGroup>

## 3. (Optional) Enable Server-to-Server notifications

Qonversion checks user receipts regularly and does not require server-to-server notifications from Apple or Google. Nevertheless, due to these notifications, your analytics charts, third-party integrations and webhooks will work much closer to real-time.

* Guide on [Apple Server-to-Server Notifications](ios-s2s-notifications)
* Guide on [Google Developer Notifications](google-developer-notifications)

## 4. Set additional user attributes

Optionally, to improve attribution in Adjust, AppsFlyer, Singular, or to match Qonversion revenue events to users in [third-party tools](integrations-overview), you can share with us such attributes as User Identifier, IDFA (Identifier for Advertisers, iOS 14.5+ only) or ASID (App set ID, Android 12+ only). Please, follow [this guide](user-properties#custom-user-properties) to learn more.

***

What’s Next

* [Apple Server-to-Server Notifications](ios-s2s-notifications)
* [Google Developer Notifications](google-developer-notifications)
