简体   繁体   English

Google DFP异步代码上的自定义代码

[英]Custom code on Google DFP asynchronous tag

I need to run a campaign on Google DFP using a custom code that will add a full screen, responsive div, above my website. 我需要使用自定义代码在Google DFP上运行广告系列,该代码将在我的网站上方添加全屏响应式div。 The problem, here: it just works using synchronous Google DFP tags, not asynchronous -- and it must be asynchronous. 问题出在这里:它仅适用于同步Google DFP广告管理系统代码,而不是异步工作-而且必须是异步的。

I really don't know what the problem is (maybe the fact that the adsize is 1x1 and the iFrame don't know it should expands? Maybe my whole code should be out of the iFrame?), but I know the ad is loaded using a Friendly iFrame... 我真的不知道问题出在哪里(也许是adsize为1x1,而iFrame却不知道它应该扩展吗?也许我的整个代码都应该在iFrame之外?),但是我知道广告已加载使用友好的iFrame ...

How could I make this happen? 我怎样才能做到这一点?

Here's the code that was supposed to appear above my website. 这是应该显示在我的网站上方的代码。

<!-- INTERSTITIAL -->
<div class="container-fluid">
  <a href="%%CLICK_URL_UNESC%%[%URL%]" target="[%TARGET%]">
  <div id="AD_TakeOver">
<span class="FloatRight Exo PaddingRight16" style="position: fixed; right: 8px;" title="Anuncie você também no JUDÃO! Entre em contato. :)">
<svg style="vertical-align: middle;" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 2000 2000" height="16" width="16"><path d="M1840.478 1080.596l61.522-426.8-397.714 61.775 240.748-329.09-333.15-243.29-264.875 362.072-51.6-331.62L668.593 114l66.246 425.767L98 328.564l394 544.24-302.02 46.91-61.522 426.798 454.81-70.64-268.363 366.838L648.055 1886l244.294-333.94 42.535 273.38 426.96 60.56-65.61-421.678 362.303 264.58 243.462-332.8-367.053-268.05z" fill="#FFF"/></svg> PUBLICIDADE</span>

<div class="Bottom" style="text-align: center;">
<svg style="margin-top: 62px;" xmlns="http://www.w3.org/2000/svg" width="32" height="32" viewBox="0 0 306 306"><path fill="#FFF" d="M270.3 58.65L153 175.95 35.7 58.65 0 94.35l153 153 153-153"/></svg>
</div>
  </div></a>
    </div>

<style>
#AD_TakeOver{
background-image: url("[%IMAGE%]");
-webkit-background-size:cover!important;
-moz-background-size:cover!important;
-o-background-size:cover!important;

background-size:cover!important;
background-attachment:fixed!important;
background-position:center!important;
background-repeat:no-repeat!important;
height: 100vh;
position:relative;
border-bottom:8px SOLID #000;
border-top:1px SOLID #000;
color:#FFF; }

#AD_TakeOver .Bottom {
position:absolute;
bottom:0;
background-color:transparent!important;

background:url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAIAAAB4CAQAAAEFAdueAAAAhUlEQVQoz3WQ0Q5DIQhDTwtu///He9jVobKEkFKaFgWZMGmGGeY1613wMGkS/AW7sopHEct4r5j9qOzIKPpqIrChc15YJgufpa9E/w+906NErK32xOe8DiOEjLABjIhnvFoYn9s5mlwolrjjjq12XdaMy6CzUsPZuNzcPUbV4FjUL/mN+gBXngOnAbq0QwAAAABJRU5ErkJggg==) repeat-x;

background-size:2px 120px;
border-bottom:0!important;
overflow:hidden!important;
height:120px!important;
max-height:120px!important;
width:100%;
vertical-align:bottom;
line-height:120px;}

</style>
<!-- /INTERSTITIAL -->`

So the code example is the code that's specified in a creative? 代码示例就是广告素材中指定的代码吗?

The problem is exactly as you stated! 问题与您所说的完全一样! The reason it works in the synchronous version is because the code is inserted in the DOM directly. 它在同步版本中起作用的原因是因为代码直接插入到DOM中。 In case of asynchronous it's inside an iframe with a width and height of 1px. 在异步情况下,它位于宽度和高度为1px的iframe中。

I'm not a big fan of having that much HTML/CSS code inside a creative. 我不太喜欢在广告素材中包含这么多的HTML / CSS代码。 There are a few solutions: 有几种解决方案:

  1. use a rich media provider (costs money and for something this 'simple', I'd go with approach 2) 使用富媒体提供商(花费金钱以及“简单”的事情,我会采用方法2)
  2. write a JS solution (I believe that's how RMP's work, but I haven't investigated it) 编写JS解决方案(我相信这就是RMP的工作方式,但我尚未对其进行调查)

Approach 2: 方法二:

Either write some JS that's called inside the creative to set the width and height of the iframe OR (and what I prefer) 编写一些在广告素材中调用的JS来设置iframe的宽度和高度或(以及我喜欢的)

Inside your creative, write something like 在您的广告素材中,编写类似

<script>
showInterstitial('%%CLICK_URL_UNESC%%[%URL%]', '[%TARGET%]', '[%IMAGE%]')
</script>

All the HTML and CSS (except the background-image css of #AdTakeover) code can be moved to the sites html/css-folders. 所有HTML和CSS(#AdTakeover的背景图片CSS除外)代码都可以移至html / css-folders网站。

You could add the interstitial-html to every page with display: none. 您可以将interstitial-html添加到每个带有显示的页面:无。 Once this function is called, you can change it to display: block and update the required DOM-elements (the link, the background-image with an inline-style on the #AdTakeover) etc. 调用此函数后,您可以将其更改为显示:阻止和更新所需的DOM元素(链接,#AdTakeover上的行内样式为背景的图像)等。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM