Analytics - Embedded Browser Events Guide
  • 01 Aug 2023
  • 1 Minute to read
  • Contributors
  • Dark
    Light
  • PDF

Analytics - Embedded Browser Events Guide

  • Dark
    Light
  • PDF

Article summary

Analytics - Embedded Browser Events Guide Document

The Webtrends SDK provides a method of sharing session information between a parent application, and an embedded UIWebView. After following the steps outlined in Implementation, any app implementing the iOS SDK will be able to see and log events generated by the Webtrends JavaScript tag.

Requirements

The native app must implement the Webtrends Mobile Library for iOS, the web content must be tagged with the Webtrends JavaScript tag, and you must be familiar with iOS UIWebViews.

Implementation

Using WKWebview
When using WKWebview, conform to WKNavigationDelegate, and implement -webView:decidePolicyForNavigationAction:decisionHandler: Include the following inside your method:

Swift

func webView(webView: WKWebView, decidePolicyForNavigationAction navigationAction:
WKNavigationAction, decisionHandler: (WKNavigationActionPolicy) -> Void) {
    let shouldStart = WTWebViewDelegate.shouldStartLoadWithRequest(navigationAction.request)
    if !shouldStart {
        decisionHandler(.Cancel)
        return
    }
    // Any custom decision policy code. Make sure your code calls decisionHandler with your chosen action policy.
}

Objective-C

- (void)webView:(WKWebView *)webView decidePolicyForNavigationAction:(WKNavigationAction *)navigationAction decisionHandler:(void (^)(WKNavigationActionPolicy))decisionHandler
{
    BOOL shouldStart = [WTWebViewDelegate shouldStartLoadWithRequest:navigationAction.request];
    if (!shouldStart)
    {
        decisionHandler(WKNavigationActionPolicyCancel);
        return;
    }
    // Any custom decision policy code. Make sure your code calls decisionHandler with your chosen action policy.
}

Was this article helpful?