测试已测试 | ✗ |
语言语言 | Obj-CObjective C |
许可证 | 自定义 |
发布最近发布 | 2016年9月 |
由Derek Kong,Jason Zhang,Sahan Peiris,Eric Kim维护。
重要!!:请查阅我们完整的集成文档在此处。本指南只会帮助您设置配置。
pod 中包含三个文件:
注意:在 YozioDefaults.plist 中有 3 个密钥。
logging_enabled
允许您开启或关闭 Yozio 记录。request_timeout
允许您修改 Yozio SDK 等待 Yozio 后端检索元数据的最大时间。use_sf_safari_view_controller
确保Yozio使用 Safari 的视图控制器。为了能够使用 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 8.x模拟器上的Safari将无法正确验证。用户代理存在一个bug,将会影响Yozio iOS匹配机制
验证步骤:(必须按照以下顺序进行操作)
YozioDefaults.plist
,将logging_enabled
更改为true。如果您想的话,可以在Yozio Console
> SuperLinks
> Organic Links
> 您的测试SuperLink名称
(Yozio仪表板大约每15分钟更新一次)中验证您测试SuperLink的点击和安装归因。
Yozio iOS SDK v2.0及更高版本支持iOS 9的100%安装匹配准确性。我们利用SFSafariViewController跟踪通过Yozio SuperLink安装您的应用的用户。100%匹配准确性仅适用于满足以下先决条件的用户
为了实现100%匹配准确性...
[Yozio handleOpenURL?url]
发送新安装元数据和跟踪深链接点击。use_sf_safari_view_controller
设置为"YES"。登录到Yozio Console
> 设置
> 默认重定向设置
,确保您的设备深链接标志处于开启状态。然后,输入您的深链接URL。
或者您也可以修改单个SuperLink的重定向设置;只需导航到Yozio Console左侧面板上的SuperLinks
> 有机链接
中的链接结束页面,并点击编辑
来配置特定的SuperLink。
在您的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`.