如何在Google跟踪代码管理器中添加Adsense [英] How to add Adsense in Google Tag Manager

查看:110
本文介绍了如何在Google跟踪代码管理器中添加Adsense的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想使用Google跟踪代码管理器来投放Adsense,因此我也可以使用其他来源的其他广告.我发现各个站点的答案很少,但不足以理解.如果可以在GTM中使用Adsense代码,请在此输入输入内容,如果可以的话,该如何输入?我也使用DFP广告管理系统,如果我必须使用DFP广告管理系统,那么情况会怎样.

I want to use Google Tag Manager to serve Adsense so I also can use other ads from other sources. I found few answers across the sites but not enough to understand. I would appreciate input here if it is possible to use Adsense code in GTM, if yes how? I also use DFP, if I have to use DFP then how it would be.

推荐答案

我假设您已经在网站上运行了Google跟踪代码管理器(GTM)?

I assume you already have Google Tag Manager (GTM) running on your site?

  1. 在您的GTM工作区中,点击屏幕左侧的变量
  2. 创建一个新的用户定义变量并将其命名为ClientID
  3. 将变量配置为常量.输入的值是您的AdSense客户ID
  4. 在您的GTM工作区中,点击屏幕左侧的标签
  5. 创建一个名为AS的新标签-页面视图-所有
  6. 由于AdSense的GTM中没有内置标记,因此您需要使用自定义HTML"标记.
  7. 将下面显示的HTML代码复制并粘贴到GTM中.
  8. 选择触发器的所有页面"视图
  9. 在预览模式下测试您的更改
  10. 一切正常后,将更改发布到LIVE.
  1. Click on Variables on the left side of the screen within your GTM workspace
  2. Create a new user defined variable and call it asClientID
  3. Configure the variable as a Constant. The value to enter is your AdSense Client ID
  4. Click on Tags on the left side of the screen within your GTM workspace
  5. Create a new Tag called AS - Page view - ALL
  6. Because there is no built-in tag in GTM for AdSense you need to use the Custom HTML tag.
  7. Copy and Paste the HTML code shown below into GTM.
  8. Select the trigger All Page views
  9. Test your changes in preview mode
  10. Once everything is working publish the changes to LIVE.

<script async src="//pagead2.googlesyndication.com/pagead/js/adsbygoogle.js"></script>
<script>
  (adsbygoogle = window.adsbygoogle || []).push({
    google_ad_client: "{{asClientID}}",
    enable_page_level_ads: true
  });
</script>

如您所见,我们正在步骤1和2中创建的脚本中使用{{asClientID}}.创建此变量的原因是灵活性.如果您需要更改ID,可以在变量而不是代码中进行更改.

As you can see we are using {{asClientID}} in the script which you have created in step 1 and 2. The reason for creating this variable is flexibility. If you need to change the ID you change it within the variable and not within the code.

注意:通过GTM实施AdSense并非最佳做法,但有可能.

NOTE: that it is not best practice to implement AdSense via GTM, but it is possible.

希望这是您想要的.请让我知道它是否适合您. :-)

Hopefully this is what you are looking for. Please do let me know if it works for you. :-)

这篇关于如何在Google跟踪代码管理器中添加Adsense的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆