# 深度链接

> 通过实现深度链接将 Web Offerwall 集成到您的网站或移动应用中。

直接链接提供了一种将您的网站链接到 Offerwall 的非常简单的方法。在显示 Offerwall 的任何位置都可以链接到以下 URL：

```text
https://rewards.unity.com/owp/web/link/<SDK_KEY>/u/<USER_ID>
```

## 必需参数##required-parameters

* **SDK\_KEY** - Tapjoy 提供的 SDK 密钥
* **USER\_ID** - 您需要提供用户 ID，以便能够为用户正确发放奖励。如需了解更多信息，请参阅[自管货币](/grow/offerwall/monetization/virtual-currency/self-managed-currency.md)。

> **Note:**
>
> 因为 **USER\_ID** 是 URL 的一部分，所以必须确保其采用 URL 安全格式或经过 URL 编码。

## 可选参数##optional-parameters

### 用户隐私##user-privacy

为了实现用户隐私，可以向 URL 添加查询参数。如需了解每个标志的更多信息，请参阅[用户隐私](/grow/offerwall/web/advanced/user-privacy.md)。

```text
https://rewards.unity.com/owp/web/link/<SDK_KEY>/u/<USER_ID>?gdpr=1&cgdpr=1&...
```

| 选项            | 查询参数名称              | 默认值    | 描述                                                               |
| ------------- | ------------------- | ------ | ---------------------------------------------------------------- |
| 用户是否受 GDPR 约束 | `gdpr`              | `0`    | 如果用户受 GDPR 约束，值必须为 `1`                                           |
| GDPR 同意       | `cgdpr`             | `0`    | `0` 表示用户不同意，`1` 表示用户同意                                           |
| 低于同意年龄        | `below_consent_age` | `0`    | `1` 和 `0` 值分别表示用户是否低于同意年龄                                        |
| 美国隐私          | `us_privacy`        | `1---` | 如需查看值的描述，请参阅[用户隐私](/grow/offerwall/web/advanced/user-privacy.md) |

### 事件名称##event-name

`event_name` 参数用于选择在您的网站或移动应用中加载的[广告位](../../monetization/dashboard/placements)。加载广告位后，Tapjoy 会渲染与该广告位关联的[内容卡片](../../monetization/dashboard/offerwall-cards)。

如果省略 `event_name`，Tapjoy 默认加载标准 Offerwall。

> **Important:**
>
> 如果省略&#x20;
>
> `event_name`
>
> &#x20;参数，请先在 Tapjoy 后台中创建&#x20;
>
> `#WebOfferwall`
>
> &#x20;广告位并将其关联到内容卡片，然后再使用 URL。如需相关说明，请参阅“广告位”文档的
>
> [创建广告位](../../monetization/dashboard/placements#create-a-placement)
>
> 一节以及“Offerwall 卡片”文档的
>
> [创建 Offerwall](/grow/offerwall/monetization/dashboard/content-cards.md#create-a-content-card)
>
> &#x20;一节。

使用以下深度链接格式通过 event\_name 指定广告位。

```text
https://rewards.unity.com/owp/web/link/<SDK_KEY>/u/<USER_ID>?event_name=<PLACEMENT_NAME>
```

### 用户标签##user-tags

Web Offerwall 支持使用[用户标签](/grow/offerwall/monetization/dashboard/targeting.md)进行细分段定向投放。您可以使用 `user_tags[]=` 传递多个用户标签。

```text
https://rewards.unity.com/owp/web/link/<SDK_KEY>/u/<USER_ID>?user_tags[]=<TAG1>&user_tags[]=<TAG2>
```

### 自定义参数##custom-parameter

您可以使用自定义参数 `cp` 传递用户定义的值，用于追踪点击和转化的具体详细信息。

```text
https://rewards.unity.com/owp/web/link/<SDK_KEY>/u/<USER_ID>?cp=xxx
```

## 使用 iframe 进行嵌入##embedding-with-iframe

在 iframe 中嵌入 Web Offerwall 时，必须确保 iframe 的大小不超过设备的屏幕视口，这一点至关重要。否则，会导致 Instruction CTA Button（操作说明引导按钮）出现在可见视口之外，用户需要向下滚动到底部才能访问该按钮。

![iframe 中嵌入的 Web Offerwall 示例，说明超大 iframe 如何将 Instruction CTA 按钮推到可见视口之外。](/api/media?file=/grow/media/images/webofferwall_iframe.jpg)

通过遵循这些准则，开发者可以最大限度提高 Web Offerwall 产品的实用性和用户参与度，确保随时能访问重要的 UI 元素。

## 移动应用中的 Web Offerwall##web-offerwall-from-mobile-apps

通过将链接加载到 WebView 中，也可在移动应用中使用 Web Offerwall。

### 示例##examples

#### Android##android

由于 Web Offerwall 尚未完全支持 Android 返回按钮，因此建议您覆盖 Android 返回按钮并实现您自己的 UI 来关闭 WebView。这样可以防止用户无意中关闭 WebView，并允许他们改用 OW 中的导航 UI。

1. **Android**

   ```java
   void showWebOfferwall() {
     final WebView webView = new WebView(requireContext());
     webView.getSettings().setJavaScriptEnabled(true);
     webView.getSettings().setDomStorageEnabled(true);
     webView.getSettings().setMediaPlaybackRequiresUserGesture(false);
     webView.setBackgroundColor(Color.TRANSPARENT);
     webView.loadUrl("https://rewards.unity.com/owp/web/link/sdk_key/u/user_id");

     RelativeLayout.LayoutParams paramsWebView = new RelativeLayout.LayoutParams(RelativeLayout.LayoutParams.MATCH_PARENT, RelativeLayout.LayoutParams.MATCH_PARENT);
     Dialog dialog = new Dialog(requireContext(), android.R.style.Theme_Black_NoTitleBar_Fullscreen);
     dialog.addContentView(webView, paramsWebView);

     // Handle backbutton
     dialog.setOnKeyListener(new DialogInterface.OnKeyListener() {
       @Override
       public boolean onKey(DialogInterface dialogInterface, int keyCode, KeyEvent event) {
         if (keyCode == KeyEvent.KEYCODE_BACK && event.getAction() == KeyEvent.ACTION_UP) {
           if (webView.canGoBack()) {
             webView.goBack();
           }
         }
         // return true to prevent closing the WebView
         return true;
       }
     });

     dialog.show();
   }
   ```

2. **iOS (Objective-C)**

   ```objective-c
   - (IBAction)showOfferwallAction:(id)sender {
     WKWebViewConfiguration* configuration = [[WKWebViewConfiguration alloc] init];
     configuration.allowsInlineMediaPlayback = YES;
     configuration.allowsAirPlayForMediaPlayback = NO;

     WKWebView* webview = [[WKWebView alloc] initWithFrame:self.view.frame configuration:configuration];
     [webview setUIDelegate:self];

     [webview loadRequest:[NSURLRequest requestWithURL:[NSURL URLWithString:@"https://rewards.unity.com/owp/web/link/sdk_key/u/user_id"]]];
     [self.view addSubview:webview];
   }

   // Open external browser for window.open() or target = _blank
   - (WKWebView *)webView:(WKWebView *)webView
   createWebViewWithConfiguration:(WKWebViewConfiguration *)configuration
      forNavigationAction:(WKNavigationAction *)navigationAction
           windowFeatures:(WKWindowFeatures *)windowFeatures {
     NSURL *url = navigationAction.request.URL;
     [[UIApplication sharedApplication] openURL:url options:@{} completionHandler:^(BOOL success) {
       if(!success) {
         NSLog(@"Failed to open URL: %@", [url absoluteString]);
       }
     }];
     return nil;
   }
   ```
