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.
- 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.
- Now click here and register our app in StreetHawk to get our AppKey.
![]()
- Let's add some permissions to our app needed for StreetHawk.
- <uses-permission android:name="android.permission.INTERNET" />
- <uses-permission android:name="android.permission.INTERNET" />
- <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
- <uses-permission android:name="android.permission.GET_TASKS" />
- <uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" />
- 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.
- <application>
- <receiver android:name="com.streethawk.library.core.StreethawkBroadcastReceiver" android:enabled="true" android:exported="true">
- <intent‐filter>
- <action android:name="android.location.PROVIDERS_CHANGED" />
- <action android:name="android.intent.action.TIMEZONE_CHANGED" />
- <action android:name="android.intent.action.BOOT_COMPLETED" />
- <action android:name="android.net.conn.CONNECTIVITY_CHANGE" />
- <action android:name="com.streethawk.intent.action.gcm.STREETHAWK_APP_STATUS_CHK" /> </intentĀ]filter>
- </receiver>
- <service android:name="com.streethawk.library.core.StreetHawkCoreService" android:enabled="true" android:exported="true"> </service>
- </application>
- Add the following namespace to add component to our activity.
- using Com.Streethawk.Library.Core;
- Now we can add some code in OnCreate to set AppKey.
- StreetHawk.Instance.SetAppKey ("<YOUR_APP_KEY>");
- StreetHawk.Instance.Init (Application);
- 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
- StreetHawk.Instance.TagString (String key, String string_value );
Tag numeric value - StreetHawk.Instance.TagNumeric (String key, Double numeric_value);
Increment Tag - StreetHawk.Instance.IncrementTag (String key);
Remove Tag - StreetHawk.Instance.RemoveTag (String key);
Check attached sample for more tags and info.