Skip to content

Growth

Introduction

StreetHawk Growth component lets your user share your application with friends. Also the feature can be extended to invite the new user to a deeplinked page inside your application. Create a Share button inside your application and call InviteFriendsToDownloadApplication to generate the share url. StreetHawk SDK will then ask user ways to share the generated url. That is (email, post on Facebook etc). Below are the APIs which generates sharable URL. A scheme for deeplinking is required for StreetHawk growth.

Pre-requisites

StreetHawkGrowth component depends on StreetHawk's Analytics components. This document assumes that you have already integrated StreetHawkAnalytics component. if not then click here for detailed documentation on StreetHawkAnalytics components which describes steps to integrate Analytics component.

Integration Steps


  • Include StreetHawk Growth Component
    1.In Xamarin Studio, double click on Components folder
    2.Click on "Get More Components", and search for StreetHawk Growth. Click Add to App
    3.Once downloaded, click on Add to Project

  • Modify AndroidManifest.xml

Add the following code in application tag of AndroidManifest.xml.

<manifest>
...

<application> 
...

    <receiver
            android:name="com.streethawk.library.growth.Register"
            android:enabled="true" >
            <intent-filter>
                <action android:name="com.android.vending.INSTALL_REFERRER" />
            </intent-filter>
        </receiver>

<application>
</manifest>
  • Include Statements

Add the following include statements

using Com.Streethawk.Library.Growth;
using Com.Streethawk.Library.Core;

// Add for deeplinking
using Android.Content;

Register deeplink parameters such as scheme and host to the activity which needs to be launched with deeplink URL.

... 
// Add for deeplinking
    [Activity (Label = "XamGrowth", MainLauncher = true, Icon = "@mipmap/icon")]
    [IntentFilter (new[]{Intent.ActionView},
        Categories=new[]{Intent.CategoryLauncher,Intent.CategoryBrowsable,Intent.CategoryDefault},
        Icon="@mipmap/icon",
        DataScheme="<DEEPLINK_SCHEME>", // define scheme here
        DataHost="<DEEPLINK_HOST>")]      // define host here

    public class MainActivity : Activity,ISHEventObserver
... 
  • Initialise StreetHawk

Set application's app_key and call StreetHawk Init from OnCreate function of your application's launcher class as shown below

namespace XamGrowth
{
    // Add for deeplinking
    [Activity (Label = "XamGrowth", MainLauncher = true, Icon = "@mipmap/icon")]
    [IntentFilter (new[]{Intent.ActionView},
        Categories=new[]{Intent.CategoryLauncher,Intent.CategoryBrowsable,Intent.CategoryDefault},
        Icon="@mipmap/icon",
        DataScheme="shsample", // define scheme here
        DataHost="setparams")] // define host here


    public class MainActivity : Activity,ISHEventObserver,IGrowth
    {
        protected override void OnCreate (Bundle savedInstanceState)
        {
            Xamarin.Insights.Initialize (XamarinInsights.ApiKey, this);
            base.OnCreate (savedInstanceState);
            // Set our view from the "main" layout resource
            SetContentView (Resource.Layout.Main);
            StreetHawk.Instance.SetAppKey (<APP_KEY>);
            StreetHawk.Instance.Init (Application);
        }
    }
}
  • Add Growth module

Implement ISHEventObserver to get notified when an install is successfully registered with StreetHawk. Inside OnInstallRegisterd() function, call AddGrowthModule() as shown below for successfully inferring if the given instance of application has resulted due to the shared url.

public class MainActivity : Activity,ISHEventObserver
    {
...
        // Add growth module after install is registered with StreetHawk server
        public void OnInstallRegistered(string installId){
            Growth.GetInstance (this).AddGrowthModule ();
        }

    }

Call originateShareWithCampaign to generate universal sharable link which your application user can share with his friends.

// Implement IGrowth to receive sharable url generated by StreetHawk
public class MainActivity : Activity,ISHEventObserver,IGrowth
    {
        ...

        public void GenerateShareLink(){

                string ID = "ShareViaFacebook";
                string shareLink = "recipeApp://homepage?recipe=chocolatechipcookie";
                string utm_source = "Facebook";
                string utm_medium = "cpc";
                string utm_term = "facebookAdd";
                string campaign_content = "best chocolate chip cookie recipe";
                string default_url = "http://recipeApp.com/chocolatechipcookie";

                Growth.GetInstance(this).GetShareUrlForAppDownload(ID,shareLink,utm_source,utm_medium,utm_term,campaign_content,default_url,this);
            };
        }



        public void OnReceiveShareUrl(string shareUrl){
            //Provide ways to share url here.
            Android.Util.Log.Info ("StreetHawk", "Share Url " + shareUrl);
        }



        public void OnReceiveErrorForShareUrl(JSONObject errorResponse){


        } 

where,

Variable Description
utm_campaign ID to be used in StreetHawk analytics
URI Deeplink URI of the page which needs to be deeplinked
utm_source source where url will be posted. (Example facebook)
utm_medium medium for posting the url (Example cost per click or CPC)
utm_term Keywords for campaign (Example facebook adv)
campaign_content Description of campaign (5 minutes chocolate chip cookie)
default_url Fallback url for non supported platforms http://www.recipeapp.com/recipe/112233
object Implementation of IStreetHawkGrowth. If null, SDK will invoke it's own app picker and catch the utm_source as per user's selection.