Javascript 如何在React应用程序中为Google Publisher标记配置单请求体系结构?
我正在尝试在React应用程序中为Google Publisher标记实现enableSingleRequest()。 我按照谷歌的建议进行了设置:Javascript 如何在React应用程序中为Google Publisher标记配置单请求体系结构?,javascript,reactjs,gpt,Javascript,Reactjs,Gpt,我正在尝试在React应用程序中为Google Publisher标记实现enableSingleRequest()。 我按照谷歌的建议进行了设置: this.googletag.cmd.push(() => { if (this.props.enableSingleRequest) { // Infinite scroll requires SRA this.googletag.pubads().enableSingleRequest(
this.googletag.cmd.push(() => {
if (this.props.enableSingleRequest) {
// Infinite scroll requires SRA
this.googletag.pubads().enableSingleRequest();
}
// add support for async loading
this.googletag.pubads().enableAsyncRendering();
// collapse div without ad
this.googletag.pubads().collapseEmptyDivs();
// load ad with slot refresh
this.googletag.pubads().disableInitialLoad();
// enable google publisher tag
this.googletag.enableServices();
});
我在其中一个页面上有6个广告,我仍然看到6个请求。
我还看到多个插槽都有完全相同的广告,这就是SRA
用来解决的问题。
我有一个react adComponent
,在每个插槽中加载。
我是否需要重新设计单个ADSLOT的加载方式?
也许使用redux是因为似乎每页都应该调用enableSingleRequest(),而您应该只调用display()一次,以便在该调用中包含所有要显示的广告。
感谢您的帮助
如何在react应用程序中为Google Publisher标记配置单请求体系结构?
谢谢:)
更新:
我已经找到了线索,但具体实施细节还不清楚。
这是关于enableSingleRequest()的google文档:
所以,现在我想知道,当adSlot组件只知道当前呈现的google publisher标记的id时,如何在react中实现这一点?我需要找出一些方法,在页面加载时通过一个请求传递所有id
Create one SRA request with all ad slots to best serve guaranteed
roadblocks or competitive exclusions, instead of sending
SRA requests with one ad slot at a time.