Getting Mobile App Installation Source

If you want to start tracking the source a user installed a mobile app from, for example, to evaluate the efficiency of a promotion campaign and build further communication based on this data, just follow this guide:

  1. Add the AppsFlyer library
pod 'AppsFlyerFramework'
  1. Integrate AppsFlyer into your project by following the instructions.

  2. In Signing & Capabilities, add the subdomain to the Associated Domains section. Make sure the subdomain is created as part of the template setup process.

  3. Implement onConversionDataSuccess from the AppsFlyerLibDelegate protocol.
    This method is called on the first app install attributed to a link and provides key user attribution data, including install details, the media source, and the campaign.

    Use the sample code below as a template for your implementation.

    func onConversionDataSuccess(_ data: [AnyHashable: Any]) {
            print("onConversionDataSuccess data:")
            for (key, value) in data {
                print(key, ":", value)
            }
    
            if let status = data["af_status"] as? String {
                if status == "Non-organic" {
                    if let sourceID = data["media_source"],
                       let campaign = data["campaign"] {
                        print("This is a Non-Organic install. Media source: \(sourceID)  Campaign: \(campaign)")
                    }
                } else {
                    print("This is an organic install.")
                }
                if let is_first_launch = data["is_first_launch"] as? Bool,
                   is_first_launch {
                    print("First Launch")
                } else {
                    print("Not First Launch")
                }
            }
        }
  4. Create a method or ask your Maestra Forward Deployed Marketer to create a method to trigger an action and/or populate a custom field.

  5. Send the resulting sourceID string to the action’s custom field in Maestra.

Mindbox.shared.executeAsyncOperation(operationSystemName:"<operationSystemName>" json: "{<Request Body with the Retrieved sourceId>}")