User-invite attribution


Attribute and record new installs when existing users refer others to use your apps.

Want to see a full example? check out the recipe:

Implement user-invite attribution

To implement user-invite attribution:

  1. Set up Unified Deeplinking (UDL) if you haven't.

  2. In AppDelegate, import AppsFlyerLib if you haven't:

    import com.appsflyer.AppsFlyerLib
  3. In AppDelegate, set a OneLink template using appInviteOneLinkID (The template ID is provided by the marketer):

    AppsFlyerLib.shared().appInviteOneLinkID = "H5hv" // Set the OneLink template ID for user-invitation links



    Call setAppInviteOneLink before calling start.

  4. In a ViewController, import AppsFlyerLib if you haven't:

    import com.appsflyer.AppsFlyerLib;
  5. Call AppsFlyerShareInviteHelper.generateInviteUrl and pass it a AppsFlyerLinkGenerator and a completionHandler:

        linkGenerator: {
            (_ generator: AppsFlyerLinkGenerator) -> AppsFlyerLinkGenerator in
                generator.addParameterValue(fruitName, forKey: "deep_link_value")
                generator.addParameterValue("user_referrer", forKey: "deep_link_sub1")
                return generator
        completionHandler: {
            (_ url: URL?) -> Void in
                if url != nil{
                // Step 6: Do something with string, for example, copy url to clipboard:
                // UIPasteboard.general.string = (url!.absoluteString)
                print("url is nil")

    Based on the marketer's definition, configure the AppsFlyerLinkGenerator as follows:

    • Set attribution parameters, using AppsFlyerLinkGenerator's setters.
    • Set deeplinking parameters, using AppsFlyerLinkGenerator's addParameterValue():
      • deep_link_value: The view the referred user should be deep-linked into.
      • deep_link_sub1: Referrer's identifier. Can be used to reward the referrer.
  6. In the completionHandler, check if the URL was created successfully (url not nil) and retrieve the generated URL.

  7. Log the invite using logEvent:

    AppsFlyerLib.shared().logEvent(AFEventInvite, withValues: nil);

Did this page help you?