~~Title:Cobub Razor Windows Phone Developer Guide - Mobile Apps Marketing Platform of Open Source - Mobile Analytics & Mobile Push Notification Solutions - Cobub Mobile Developer Center~~
{{description>Cobub Razor is an Open Source Mobile Analytics. The goal of this document is to explain usage rules of Cobub Razor Windows Phone SDK for facilitating mobile app developers.}}
{{keywords>Cobub Razor,open source mobile analytics,mobile analytics,mobile app analytics, windows phone, developer guide}}
====== Cobub Razor Windows Phone Developer Guide ======
===== 1 Overview =====
==== 1.1 Documentation Goal ====
The goal of this document is to explain usage rules of Cobub Razor Windows Phone SDK for facilitating mobile app developers.
==== 1.2 Application Scope ====
This document is for Windows Phone SDK developers, which uses the Open Source Mobile Analytics – Cobub Razor.
==== 1.3 Terms and Abbreviations ====
Cobub Razor - [[en:start|The Open Source Mobile Analytics]]
==== 1.4 Relevant Documentation ====
NA
===== 2 Basic Setup Guide =====
==== 2.1 Obtain AppKey ====
First please setup the Web Server of Cobub Razor ([[en:razor:installation|instruction]]), then register App at web server and fill App info after login. Once App is created successfully, you could obtain **AppKey**.
==== 2.2 SDK Usage Step ====
=== 2.2.1 Import UMSAgent.dll ===
Import Windows Phone SDK into your project.
VS users right click own project “Reference” directory and select “Add Reference —>Browse”. Then select path of UMSAgent.dll. Click OK and then import is completed.
=== 2.2.2 Integration Instructions ===
We recommend you Calling
UmsAgent.UMSApi.onPageBegin("current_page_name ")
and
UmsAgent.UMSApi.onPageEnd("current_page_name ")
in all pages. If not , Page View report and some related data statistics reports will not be available on the Web Server.
=== 2.2.3 Note ===
* Check to make sure that AppKey has been correctly written.
* You must invoke //UmsAget.UMSApi.onAppstart(string appkey,string url)// firstly
* SDK could help you catch exit exception during App usage and send error data statistics report to server. Error report includes App version, OS version, device type and stack trace of program exception. These data will help you debug the App errors.
* Different channels have different AppKeys.
===== 3 API introduce =====
==== 3.1 Init SDK ====
UMSAgent.UMSApi.onAppStart(string appKey,string url)
**Appkey:** the key of App, which is produced by the server;
**url:** the url of your server.
You MUST invoke this API in **Application_Launching(object sender, LaunchingEventArgs e)** method of the **APP.xmal.cs** file .
Otherwise, the SDK will not work and other APIs of this SDK bellow can not be used.
==== 3.2 Log ====
UMSAgent.UMSApi.setDebugMode(boolean isDebugMode);
**isDebugMode**
true: show Exception logs;
false: not show;
If you want to monitor errors or exceptions, invoke this API, only the errors and exceptions which ocuur after calling this method will be catched.
==== 3.3 Online Preference Configuration ====
**UmsAgent. UMSApi.updateOnlineConfig();**
Invoke this API in **Application_Launching(object sender, LaunchingEventArgs e)** and SDK will get your online configuration on the server and store this info in local.
If you don’t invoke this API, SDK will give you a default report policy to deal with the data to be uploaded to server. The version is set in the Version value in WMAppManifest.xml file.
==== 3.4 APP Update ====
**UMSAgent.UMSApi.getNewVersion();**
Invoke this API when you want the APP to check that whether Web Server has a new version of the App automatically.
If you have created a new version on the Web Server, your App will notify user to upgrade the APP. If user choose yes , system will upgrade APP automatically.
==== 3.5 Page Visit ====
**UmsAgent. UMSApi.onPageBegin(string pagename);**
**pagename**: the page you want to gather statistics
Invoke this API in the OnNavigatedTo method of the page/form . This method records the time of user enters into this page.
**UmsAgent. UMSApi.onPageEnd(string pagename);**
**pagename**: the page you want to gather statistics
Invoke this API in the **OnNavigatedFrom** method of the page . This method records the time of user leaves this page.
Note: You need to call 2 APIs above in pair.
==== 3.6 Custom Event ====
Except basic data statistics analysis, the SDK also supports data statistics analysis of custom event. For example, you can count AD clicks or times of video has been played. Here we provide several simple and common interfaces:
UMSAgent.UMSApi.onEvent(string event_id,string pagename);
**pagename**: the reference of current page
**event_id:** the ID of current event, defined on the Web Server and could not have spaces.
Invoke this API will send event info to the server and generate the event report on the server which analyzes sending times and changing trends corresponding to event_id, such as AD clicks, message numbers and so on.
For example, to monitor AD clicks of App in “**MainPage**”, the Event ID of which is “ ad_click“ defined on the Web Server, you need call **UMSAgent.UMSApi.onEvent(“ad_click“, “MainPage”)** in App , which will notify server that an AD click event has occurred.
**UMSAgent.UMSApi.onEvent(string event_id, string pagename, string label);**
This API is an overloaded method of onEvent(string event_id,string pagename) which will monitor the proportion of specific label in event. The label is the devision name and event_id could not have spaces.
For example, a province has a corresponding event_id and one city of which has a corresponding label in App. Thus, we can observe the proportion of event corresponding to the city in generated data statistics reports.
UMSAgent.UMSApi.onEvent(string event_id, string pagename, int acc);
For the frequent events ,you can maintain a counter for them. In this way, event that are triggered by many times will just generate one message and be sent to the server. This message includes triggered times of this event.
Here is overloaded two APIs:
**UMSAgent.UMSApi.onEvent (string event_id, string pagename,int acc);**
**UMSAgent.UMSApi.onEvent (string event_id, string pagename, string label,int acc);**
acc: triggered times of corresponding event.
==== 3.7 Bind user account ====
**UMSAgent.UMSApi. bindUserIdentifier(string userid);**
userid : user account.
You can bind user’s account information to your app when you call this function.
==== 3.8 Bind Tags ====
**UMSAgent.UMSApi.postTag(string tag);**
Bind your user’s tag and send data to server.