StreetHawk Analytics To Analyse Xamarin.Android App

Here we will discuss how to make use of StreetHawk Analytics Component in our Xamarin.Android App. StreetHawk Analytics Component is a base component of StreetHawk SDK. All other StreetHawk components can work only with the help of StreetHawk Analytics Component. It provides API which helps us to understand and identify the user and track most of the important events inside the application. Let's get started to integrate StreetHawk Analytics to our app.

StreetHawk

  1. In Xamarin Studio, right click on the Components folder of your project and select Get More Components. Search for StreetHawk Analytics, select the component and click Add to App.

     

  2. Now click here and register our app in StreetHawk to get our AppKey.



  3. Let's add some permissions to our app needed for StreetHawk.
    1. <uses-permission android:name="android.permission.INTERNET" />  
    2. <uses-permission android:name="android.permission.INTERNET" />  
    3. <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />  
    4. <uses-permission android:name="android.permission.GET_TASKS" />  
    5. <uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" />  
  4. Now we want to add a receiver tag and service tag inside our application tag in our AndroidManifest.xml to get time zone, app status, etc.
    1. <application>  
    2.     <receiver android:name="com.streethawk.library.core.StreethawkBroadcastReceiver" android:enabled="true" android:exported="true">  
    3.         <intent‐filter>  
    4.             <action android:name="android.location.PROVIDERS_CHANGED" />  
    5.             <action android:name="android.intent.action.TIMEZONE_CHANGED" />  
    6.             <action android:name="android.intent.action.BOOT_COMPLETED" />  
    7.             <action android:name="android.net.conn.CONNECTIVITY_CHANGE" />  
    8.             <action android:name="com.streethawk.intent.action.gcm.STREETHAWK_APP_STATUS_CHK" /> </intent]filter>  
    9.     </receiver>  
    10.     <service android:name="com.streethawk.library.core.StreetHawkCoreService" android:enabled="true" android:exported="true"> </service>  
    11. </application>  
  5. Add the following namespace to add component to our activity.
    1. using Com.Streethawk.Library.Core;  
  6. Now we can add some code in OnCreate to set AppKey.
    1. StreetHawk.Instance.SetAppKey ("<YOUR_APP_KEY>");  
    2. StreetHawk.Instance.Init (Application);  
  7. Now we can see some tags in StreetHawk which help to identify user and track events. All the developers are advised and may use predefined StreetHawk keys or specific custom keys of their own. It's strongly recommended that installs are tagged with StreetHawk's "sh_cuid" tag. It tags an install with a unique identifier, which is needed to link the identity of App users to users in your, and the StreetHawk backend.

Tag string

  1. StreetHawk.Instance.TagString (String key, String string_value );  
Tag numeric value
  1. StreetHawk.Instance.TagNumeric (String key, Double numeric_value);  
Increment Tag
  1. StreetHawk.Instance.IncrementTag (String key);  
Remove Tag
  1. StreetHawk.Instance.RemoveTag (String key);  
Check attached sample for more tags and info.

Up Next
    Ebook Download
    View all
    Learn
    View all