跳转到主要内容
为简洁起见,本指南将使用自闭合标签( 而非 )。大多数 JSX及其他现代编译器均支持此语法。但是,如果您在纯 HTML中编写代码,则需要手动闭合标签。 This guide will use self closing tags ( <script /> instead of <script></script>) for simplicity. Most JSX and other modern compilers will accept this syntax. However, if you are working in raw HTML, you should manually close the tags.

添加Rev脚本 Add the Rev script

了解如何将我们的脚本添加到您的网站。 Learn how to add our script to your site.
将以下脚本添加到 HTML 文件的 <head> 标签中。 Add the following script to the <head> of your HTML file.
page.html
  <script
    src="//js.rev.iq/your-domain.com"
  />
添加以下代码 Add the following code
index.js
  const script = document.createElement('script');
  script.src = '//js.rev.iq/your-domain.com';
  document.head.appendChild(script);
您也可以考虑为脚本标签添加defer属性,以优化页面初始加载速度。 You may also consider adding the defer attribute to the script tag to optimize initial page load speed.
如需针对不同用户测试其他变现服务商,可使用以下代码按条件加载 Rev 脚本。 If wanting to test with another monetization provider per client, you can use the following code to conditionally load the Rev script.
index.js
const REV_RATE = 0.1; // 10%的用户将看到Rev脚本 10% of users will see the Rev script
const shouldUseRevIq = Math.random() < REV_RATE;
const script = document.createElement("script");

if (shouldUseRevIq) {
  script.src = "//js.rev.iq/your-domain.com";
} else {
  // 加载您的其他变现服务商 Load your other monetization provider
  // 请参考该服务商的文档设置相应属性 Set the attributes based on the other vendor's documentation
}

document.head.appendChild(script);

开发模式 Development

为脚本添加dev属性,以启用开发环境广告位。 Add the dev attribute to the script to use dev placements.
将以下脚本添加到 HTML 文件的 <head> 标签中。 Add the following script to the <head> of your HTML file.
page.html
  <script
    src="//js.rev.iq/your-domain.com"
    dev
  />
添加以下代码 Add the following code
index.js
  const script = document.createElement('script');
  script.src = '//js.rev.iq/your-domain.com';
  script.setAttribute("dev", "")
  document.head.appendChild(script);

定义广告单元 Defining ad units

为元素添加data-ad属性并填写广告位名称,以标记您希望广告出现的位置。 Add the data-ad attribute with the name of the placement to mark where you want ads to appear.
<div data-ad="right-rail-1" />
<div data-ad="right-rail-2" />
<div data-ad="right-rail-3" />

data-ad-size

您可以通过添加data-ad-size属性并指定所需尺寸,来自定义广告单元。 You can customize the ad units by adding the data-size attribute with the desired size.
<div data-ad="right-rail-1" data-ad-size="300x250" />

data-kv-{key}

此外,您还可以通过添加data-kv-{key}属性,为广告单元添加定向标签。 Additionally, you can add targeting tags to the ad units by adding the data-kv-{key} attribute.
<div data-ad="right-rail-1" data-kv-page="home" data-kv-foo="bar" />