最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - Are gtag.js and gtm.js interchangeable? - Stack Overflow

programmeradmin0浏览0评论

Hi I'm new to Google Tag Manager,

I am trying to add Google Adwords Conversion Pixel to our website, and google tells me I should add the following snippet.

  gtag('event', 'conversion', {
      'send_to': 'AW-1000000/XXXXXXXX',
      'event_callback': callback
  });

Since our website is already using gtm.js,

can I convert the above snippet to the following to get the same effect?

dataLayer.push({ "event": "conversion", 
"send_to": "AW-1000000/XXXXXXXX", "event_callback": undefined})

Hi I'm new to Google Tag Manager,

I am trying to add Google Adwords Conversion Pixel to our website, and google tells me I should add the following snippet.

  gtag('event', 'conversion', {
      'send_to': 'AW-1000000/XXXXXXXX',
      'event_callback': callback
  });

Since our website is already using gtm.js,

can I convert the above snippet to the following to get the same effect?

dataLayer.push({ "event": "conversion", 
"send_to": "AW-1000000/XXXXXXXX", "event_callback": undefined})
Share Improve this question edited Sep 17, 2020 at 10:36 yodabar 4,7993 gold badges35 silver badges39 bronze badges asked Nov 30, 2017 at 20:34 dorachan2010dorachan2010 1,0913 gold badges14 silver badges21 bronze badges
Add a ment  | 

2 Answers 2

Reset to default 5

No. But you can create an Adwords conversion tag within GTM (there is a template for this, the part before the slash is the conversion id, the part after the slash the conversion label). If you want you can configure the tag via the dataLayer, but you'd still have to create a tag within GTM and apply a trigger to make this work.

Gtag.js is great for sites that don't use tag management systems. If you use GTM, then use GTM triggers and tag templates for adwords to acplish your measurement needs.

Gtag.js will be the library that replaces analytics.js, and thus replace the ga('send') type of measurement code. You have likely replaced that syntax with the GTM GA tag templates and triggers like "All Pages".

发布评论

评论列表(0)

  1. 暂无评论