YozioIOSSDK 2.2

YozioIOSSDK 2.2

测试已测试
语言语言 Obj-CObjective C
许可证 自定义
发布最近发布2016年9月

Derek KongJason ZhangSahan PeirisEric Kim维护。



  • Yozio

关于 YozioIOSSDK

重要!!:请查阅我们完整的集成文档在此处。本指南只会帮助您设置配置。

pod 中包含三个文件:

  • YozioDefaults.plist
  • libYozio.a
  • Yozio.h

注意:YozioDefaults.plist 中有 3 个密钥。

  1. logging_enabled 允许您开启或关闭 Yozio 记录。
    1. request_timeout 允许您修改 Yozio SDK 等待 Yozio 后端检索元数据的最大时间。
      1. use_sf_safari_view_controller 确保Yozio使用 Safari 的视图控制器。

Swift 支持

为了能够使用 Swift 版本的 Yozio SDK,您需要一个桥接头文件,以便 Swift 应用程序使用 Objective C 代码。

您可以将 Yozio SDK 添加到应用程序中,然后 Xcode 将提示您创建一个桥接头。在此确认将自动创建一个桥接头,文件名为 您的模块名称-Bridging-Header.h

或者,您可以创建自己的 Bridging-Header.h 文件。

在桥接头文件中,您需要包含 Yozio.h 文件。

#import <Yozio.h>

有关更多关于桥接头文件的信息,请参阅这篇文章

安装跟踪和新安装元数据回调配置

Yozio.h 包含到您的 AppDelegate.m 中,通过在 AppDelegate.m 中的 didFinishLaunchingWithOptions里粘贴以下内容,并通过参数传递 您的应用密钥您的应用密钥

//Configures the Yozio SDK. 
//Must be called when your app is launched and before any other method.
//Use the actual keys for your app per the instructions above
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
       [Yozio initializeWithAppKey:@"your_app_key"
                            secretKey:@"your_secret_key"
                                newInstallMetaDataCallback:^(NSDictionary *metaData) {
                                           NSLog(@"Got Meta Data from new install: %@", metaData);
                                              }];
                                                 return YES;
}

此代码块将尝试匹配 SuperLink 点击事件并从 Yozio 云(后端)检索元数据。如果您只想通过 Yozio 跟踪新安装,可以将 newInstallMetaDataCallback 传递为 nil。

对于通过与 Yozio SuperLink 交互而安装的任何用户,Yozio 将持续保留从 Yozio 后端接收到的元数据。如果您愿意,可以通过以下方法随时访问用户的新安装元数据

[Yozio getNewInstallMetaDataAsHash];
[Yozio getNewInstallMetaDataAsUrlParameterString];

需要代码示例吗?您可以在我们的 iOS 示例应用程序中查看实际的代码示例,Yozio 控制台 > SDK > 点击下载 iOS 示例应用程序

验证 iOS 新安装元数据返回

您可以选择两种方式来验证安装跟踪设置

  1. 通过连接到 Xcode 的真实 iPhone 设备
  2. 通过 iPhone 模拟器

注意:在iOS 8.x模拟器上的Safari将无法正确验证。用户代理存在一个bug,将会影响Yozio iOS匹配机制

验证步骤:(必须按照以下顺序进行操作)

  1. 请确保日志记录功能已启用,通过访问YozioDefaults.plist,将logging_enabled更改为true。
  2. 从您的移动设备中删除应用。
  3. 使用现有的测试SuperLink,或者创建一个新的。
  4. 点击测试的SuperLink
  5. 从Xcode安装应用并打开它。
  6. 检查调试控制台以获取信息。您应该会看到“来自新安装的数据”和一组参数。

如果您想的话,可以在Yozio Console > SuperLinks > Organic Links > 您的测试SuperLink名称(Yozio仪表板大约每15分钟更新一次)中验证您测试SuperLink的点击和安装归因。

100% 新安装匹配准确性

Yozio iOS SDK v2.0及更高版本支持iOS 9的100%安装匹配准确性。我们利用SFSafariViewController跟踪通过Yozio SuperLink安装您的应用的用户。100%匹配准确性仅适用于满足以下先决条件的用户

  • 末位用户必须处于iOS 9,使用Safari,并且不在“私密模式”下
  • 点击和首次应用启动之间的时间间隔不能超过30天

为了实现100%匹配准确性...

  1. 将SafariServices.framework添加到您的项目中(构建阶段 -> 与二进制文件链接库 -> +)。
  2. 使用[Yozio handleOpenURL?url]发送新安装元数据和跟踪深链接点击。
  3. 在YozioDefaults.plist中,将use_sf_safari_view_controller设置为"YES"。

在Yozio Console中配置iOS深链接重定向URL

登录到Yozio Console > 设置 > 默认重定向设置,确保您的设备深链接标志处于开启状态。然后,输入您的深链接URL。

或者您也可以修改单个SuperLink的重定向设置;只需导航到Yozio Console左侧面板上的SuperLinks > 有机链接中的链接结束页面,并点击编辑来配置特定的SuperLink。

实现iOS深链接跟踪代码和元数据处理工具

在您的AppDelegate.m中添加[Yozio handleOpenURL:url]。要访问Yozio深链接元数据,实现以下实用函数来解析查询字符串中的元数据。

 - (BOOL)application:(UIApplication *)application
            openURL:(NSURL *)url
             sourceApplication:(NSString *)sourceApplication
                     annotation:(id)annotation
                     {   
                            // Track deep links
                               [Yozio handleOpenURL:url];

                                     // This is a util function to parse metadata from query string,
                                        // and it will filter out Yozio internal parameters which key starts
                                           // with "__y".
                                              NSDictionary *metaData = [Yozio getMetaDataFromDeeplink:url];

                                                    NSLog(@"Got meta data from deep link: %@", metaData);

                                                          // Add your custom code to handle meta data.
                                                             return YES;
                     }
                     ```

                     Yozio will persist the last clicked deep link metadata locally. To get this metadata you can use the following helpers:

                     ```
                     [Yozio getLastDeeplinkMetaDataAsHash];
                     [Yozio getLastDeeplinkMetaDataAsUrlParameterString];
                     ```

### Verify deep link setup and metadata return

On a test device that has your iOS app installed, click on the Yozio SuperLink for your app that has metadata associated with it. Your app should open and in the Xcode debug console, you will be able to see the metadata captured. 

If you have deployed the Yozio deep link tracking code, the Yozio Console will also have recorded a deep link event for the SuperLink which was clicked. 

## Yozio Custom Events

### Tracking Yozio Default Events

Yozio has two default events: 

Default Event Name | iOS Tracking Code   
------------------ | ----------------- 
signup             | `[Yozio trackSignup];` 
payment            | `[Yozio trackPayment:12.50];`

Fire this tracking code anytime a conversion for the event occurs. 

### Tracking Custom Events

#### Step 1: Register an event to track

You can register any downstream event you'd like to track conversion for with Yozio. By default Yozio provides the events Signup & Payment, so there is no need to register those events. To register more downstream post install event to track with Yozio: 

1. Login to the [Yozio Console](http://console.yozio.com) 
2. Go to **Settings** > **Downstream Events** 
3. Add your event 
  * Enter the event name (32 character limit, no special characters) 
    * Enter an event description (optional) 
      * Click "Register Downstream Event" 

       You will receive confirmation that the event was created and your custom event will now be listed on the Downstream Events page. In addition, your custom event will now be available as a selection on all dashboards of the Yozio Console so that you may view campaign attribution results.

#### Step 2: Integrate iOS tracking code

Place the tracking code into your app to fire anytime the event occurs. Please see the Yozio iOS Sample App (Login to the Yozio Portal > "Settings" > "iOS" > click to download "iOS Sample App") for a real code example. Format the tracking code as follows:

[Yozio trackCustomEventWithName:@"您的自定义事件名称" andValue:nil];


Here is an iOS code example (please see the Yozio sample apps for more code examples):

// 触发自定义事件 - 更通用的例子 // 用户刚刚邀请10个朋友。[Yozio trackCustomEventWithName:@"invite" andValue:@"10"];


#### Step 3: Verify iOS downstream event tracking setup
Verify setup by hitting the run button in Xcode and you should see more Yozio Console logs. If you ever want to silence the logs from Yozio go to `YozioDefaults.plist`, and change `logging_enabled` to `false`.