Generating events through the native application

WebBrowser instances embedded in a native app can generate Webtrends events using JavaScript helper methods that interact with the native app to generate and send events, or using the Webtrends JavaScript tag in the embedded web content to generate and send events. Follow these instructions to use JavaScript helper methods.

The native app must implement the Webtrends Mobile Library for Windows Phone, and contain embedded web content in a WebBrowser.
  1. Create an embedded Web browser and add a ScriptNotify attribute to it.
    1. Set up a ScriptNotify event handler by adding the ScriptNotify attribute to the XAML file.
       <StackPanel x:Name="LayoutRoot" Height="358" Width="489" Background="LightBlue">
          <WebBrowser  x:Name="WB1" Source="http://localhost/HTMLPage1.htm" Height="272" Width="379" 
                       ScriptNotify="WB1_ScriptNotify" Margin="5" />
          <Button Width="200" x:Name="Button1" Content="Click to search!" Click="Button1_Click" />
    2. Add a call to WTDataCollector.Instance.triggerEvent(e.Value) in the resulting event handler:
      void WB1_ScriptNotify(object sender, NotifyEventArgs e)
  2. Add WebtrendsMobileLib.js to the content that will be loaded in the WebBrowser. WebtrendsMobileLib.js is delivered as part of the Webtrends Mobile Library for Windows Phone.
  3. Use the WebtrendsLib to generate events. In the embedded web content, use the JavaScript helper functions of the webtrendsLib object to generate events through the native app. A JavaScript helper function exists for each of the event helper functions exposed in the native Webtrends SDK. The JavaScript helper functions take the same arguments as the native helper functions.
    		<script type="text/javascript" src="js/WebtrendsMobileLib.js"></script>
    		<script type="text/javascript">	
    			function sendButtonClickEvent() {
    				var eventPath = "/HelloWorld/button/click";
    				var eventDesc = "HelloWorld Button Click Event";
    				var eventType = "click";
    				var customData = {
    					customKey : "CustomValue"
    				webtrendsLib.onButtonClick(eventPath, eventDesc, eventType, 
    			<input type="button" onclick="sendButtonClickEvent()" value="Click Me">