D.S*_*Sc. 9 reactjs google-ads-api
On my react PWA I want to track conversions in Google Adwords after, for example, sending form data. I already use the react-ga module to track pageviews which uses a UA-xxxxxx number. Now I have an Adwords number AW-xxxxxx and I can't seem to find a working example with that. Which react module can I use to send those Events to my AW-xxxxxx number?
I already took a look at really small and seemingly incomplete Adwords modules for react, but they do not include Event tracking or don't take AW-xxxxx numbers, only GTM-xxxxx.
这是我需要实现的代码:
<script async src="https://www.googletagmanager.com/gtag/js?id=AW-xxxxx"></script>
<script>
window.dataLayer = window.dataLayer || [];
function gtag(){dataLayer.push(arguments);}
gtag('js', new Date());
gtag('config', 'AW-xxxxxx');
</script>
Run Code Online (Sandbox Code Playgroud)
对于事件:
<script>
gtag('event', 'conversion', {'send_to': 'AW-xxxxx/XXXXXX'});
</script>
Run Code Online (Sandbox Code Playgroud)
我努力实施上述回应。这是完成此任务的更简单的方法。
<!-- ADDED TO TRACK GOOGLE CONVERSION -->
<script async src="https://www.googletagmanager.com/gtag/js?id=AW-XXXXXXXX"></script>
<script>
window.dataLayer = window.dataLayer || [];
function gtag(){dataLayer.push(arguments);}
gtag('js', new Date());
</script>
Run Code Online (Sandbox Code Playgroud)
componentDidMount () {
window.gtag('config', 'AW-XXXXXXXXXX');
window.gtag('event', 'conversion', {'send_to': 'AW-XXXXXXXXXX/YYYYYYYYY-ZZZZZZZZZZ'});
}
Run Code Online (Sandbox Code Playgroud)
您可以<script>
直接将标签添加到您的index.html
或使用Helmet。然后就可以打电话了window.gtag
。
不过,由于您已经在使用 Google Analytics(分析)react-ga
,所以我建议您使用 Google Analytics(分析)目标作为 Google Ads 的转化指标。按着这些次序:
这样您只需担心使用单一服务进行跟踪。
归档时间: |
|
查看次数: |
1913 次 |
最近记录: |