Skip to content



StreetHawk's Analytics Component is core component of StreetHawk SDK. The module reports various vital raw data to StreetHawk servers which is further processed and used for various analytics for your application. The module also provides API for tagging the install, identifying the users and tracking various important events inside your application. All other components of StreetHawk depends on Analytics component for it's functioning.

Integration Steps

  • Include StreetHawkAnalytics Component

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

  • Check StreetHawk.IOS.Core.dll reference

Right click project->References->Edit References..., make sure StreetHawk.IOS.Core.dll is added to project. For Unified project, add corresponding StreetHawk.IOS.Core-Unified.dll.

  • Modify Info.plist

Click Info.plist to open it, move to "Background Modes" and enable "Background fetch".

  • Initialise StreetHawk

Include StreetHawk component adding following statement:

using StreethawkIOS.Core;

Add the following code in AppDelegate.cs when launching App:

public override bool FinishedLaunching (UIApplication application, NSDictionary launchOptions)
//streethawk register install sample.
SHApp.instance ().appKey = "<App_Key>";
SHApp.instance ().enableLogs = <true/false>;
SHApp.instance ().iTunesId = "<AppStore_Id>";
SHApp.instance ().streethawkinit ();

Identify Your App Users

  • Tagging customer's unique ID
string cuid = ""; // using user's email address cuid
SHApp.instance().tagCuid (cuid);
  • Tag user language
string user_language = "en-US";
  • Tagging customer's first name
string key = "sh_first_name";
string name = "David";
SHApp.instance().tagString (key, name);
  • Tagging customer's email address
string key = "sh_email";
string email = "";
SHApp.instance().tagString (key, email);

Tag Events Inside Application

  • String value
string key = "ProductOffer";
string value = "Liked";
SHApp.instance().tagString (key, value);
  • Numeric Value
string key = "BidValue";
int value = 554.95;
SHApp.instance().tagNumeric (key, value);
  • DateTime Value
// Example code using pre-defined StreetHawk keys
string key = "sh_registered";
DateTime datetime_value = DateTime.Now
SHApp.instance().tagDatetime (key, datetime_value); // string Date time value in UTC
// Example code using custom tag
string key = "Birthday";
DateTime datetime_value = new DateTime(2014, 7, 25, 15, 33, 20);
SHApp.instance().tagDatetime (key, datetime_value);
  • Increment Tag's value
string key = "LikeButtonPressed";
SHApp.instance().incrementTag (key);


string key = "LikeButtonPressed";
SHApp.instance().incrementTag (key, 100);
  • Remove Tag
string key = "RemoveUser";
SHApp.instance().removeTag (key);

Trace Enter/Exit View

Use Track VC feature for tracking events of user entering and exiting a view controller inside your application without writing lines of code inside every ViewDidAppear and ViewWillDisappear.

public override void ViewDidLoad ()
  base.ViewDidLoad ();

public override void ViewDidAppear (bool animated)
       base.ViewDidAppear (animated);
       //trace view enter/exit
       SHApp.instance ().shNotifyViewAppear (this, this.GetType ().Name);

public override void ViewWillDisappear (bool animated)
      base.ViewWillDisappear (animated);
      //trace view enter/exit
      SHApp.instance ().shNotifyViewDisappear (this, this.GetType ().Name);

Get StreetHawk Formatted Date Time

Get the string of datetime in style yyyy-MM-dd HH🇲🇲ss.

string currentTime = SHApp.instance().getCurrentFormattedDateTime();


string certainTime = SHApp.instance().getFormattedDateTime(60*60); //second

Get Install Id

Each install has a unique StreetHawk ID, get the ID by API.

string installId = SHApp.instance().getInstallId;

or get noticed when install register successfully.

SHApp.instance ().registerEventCallBack = delegate (string installId) 
InvokeOnMainThread ( () => { UIAlertView alert = new UIAlertView ("Install
register successfully: ", installId, null, "OK", null); alert.Show ();