Package com.codename1.analytics.invite


package com.codename1.analytics.invite

Invite / referral attribution: who invited whom, who installed because of it, and what that invited cohort went on to do.

Invites mints an invite link, shares it through the native share sheet, and -- on the friend's device -- recovers the invite that caused the install. Once attribution resolves it is written as persistent analytics dimensions, so every later event, including the purchase event the framework already emits for you, arrives tagged with the campaign and the referrer. Revenue and lifetime value per campaign fall out of the reports you already have.

// On the inviter's device.
Invite invite = Invites.create(InviteRequest.create()
        .campaign("spring")
        .channel("share_sheet")
        .build());
Invites.share(invite, "Come and try this with me");

// On the friend's device, from your start() method.
Invites.setInviteListener(new InviteListener() {
    public void inviteReceived(InviteAttribution attribution) {
        // Credit attribution.getCampaign() / getCode().
    }

    public void attributionUnavailable(String reason) {
        // Ordinary: most installs are not invited.
    }
});
Invites.checkForInvite();

Everything here is gated on the analytics consent category of Analytics, and nothing is reported until consent is granted.

This package is deliberately separate from com.codename1.analytics. The Android half of the attribution links the Play Install Referrer library and declares the permission that binds to it, and the build only does that for applications that actually reference this package -- an application that merely reports analytics carries neither.