可以在Web/React上实现原生的Google广告吗?

huangapple go评论100阅读模式
英文:

It is possible to implement Native Google Ads on web/React?

问题

我正在努力在网站上实现Google原生广告,我尝试在Google网站上找到一些文档,但所有的文档都是关于移动应用的。是否有人已经尝试过这个?

已经做了以下工作:

  1. 我查阅了Google的文档。
  2. 询问聊天GPT :),得到了一些无用的信息。
  3. 进行了一些与Google广告事件的测试等。
英文:

I am struggling with implement google native ads on web, i tired to find some documentation on google site, but all refers to mobile app. Has anyone perhaps implemented this?

Already what i do:

  1. I dig through the google documentation
  2. Ask chat GPT 可以在Web/React上实现原生的Google广告吗? , give me few useless info
  3. Some tests with google ads events etc.

答案1

得分: 1

当然,你可以在Web上使用React实现原生Google广告。

你可以使用react-gpt来实现这个功能。GPT代表Google Publisher Tag,是用于Google Ad Manager的广告标记库。

例如:

import React from "react";
import { Bling as GPT } from "react-gpt";

export default function App() {
  return (
    <div className="App">
      <GPT
        adUnitPath="/4595/nfl.test.open"
        sizeMapping={[
          { viewport: [0, 0], slot: [320, 50] },
          { viewport: [750, 0], slot: [728, 90] },
          { viewport: [1050, 0], slot: [1024, 120] },
        ]}
        nativeTemplateId="10101010"
      />
    </div>
  );
}

这将创建一个使用ID为10101010的原生广告模板的原生广告组件。原生广告模板应包含您想要显示的广告资产的占位符。

要了解更多信息,请参阅npmjs上的react-gpt文档GitHub上的文档

英文:

Of course, you can implement Native Google Ads on Web using React.

You can use react-gpt for this function. GPT stands for Google Publisher Tag, which is an ad tagging library for Google Ad Manager.

For example:

import React from &quot;react&quot;;
import { Bling as GPT } from &quot;react-gpt&quot;;

export default function App() {
  return (
    &lt;div className=&quot;App&quot;&gt;
      &lt;GPT
        adUnitPath=&quot;/4595/nfl.test.open&quot;
        sizeMapping={[
            { viewport: [0, 0], slot: [320, 50] },
            { viewport: [750, 0], slot: [728, 90] },
            { viewport: [1050, 0], slot: [1024, 120] },
        ]}
        nativeTemplateId=&quot;10101010&quot;
      /&gt;
    &lt;/div&gt;
  );
}

This will create a native ad component that uses the native ad template with the ID of 10101010. The native ad template should contain placeholders for the ad assets that you want to display.

To learn more, see react-gpt doc in npmjs and github.

huangapple
  • 本文由 发表于 2023年7月4日 21:06:46
  • 转载请务必保留本文链接:https://go.coder-hub.com/76612977.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定