我有一个Wordpress页面,我需要跟踪所有的点击作为谷歌广告转换,所以我发现我可以使用整个页面作为一个链接与以下代码:
<html>
<body onclick='window.location.href="http://google.com"'>
</body>
</html>
然后我需要在每次点击时激活Google转换标签,转换脚本是:
<!-- Event snippet for Solicitar cotação conversion page
In your html page, add the snippet and call gtag_report_conversion when someone clicks on the chosen link or button. -->
<script>
function gtag_report_conversion(url) {
var callback = function () {
if (typeof(url) != 'undefined') {
window.location = url;
}
};
gtag('event', 'conversion', {
'send_to': 'AW-ID/AWID',
'event_callback': callback
});
return false;
}
</script>
好的,那么,我怎么才能让每一次点击都算作转换呢?
非常感谢。
发布于 2021-08-31 08:31:10
你的谷歌代码片段应该放在你的<head></head>标签之间。在您的子主题或活动主题中,编辑您的<head>标记所在的header.php文件。我更喜欢在wp_head()函数之前添加任何代码片段。下面是header.php的一个示例
<!doctype html>
<html <?php language_attributes(); ?>>
<head>
<meta charset="<?php bloginfo( 'charset' ); ?>" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<!-- Event snippet for Solicitar cotação conversion page
In your html page, add the snippet and call gtag_report_conversion when someone clicks on the chosen link or button. -->
<script>
function gtag_report_conversion(url) {
var callback = function () {
if (typeof(url) != 'undefined') {
window.location = url;
}
};
gtag('event', 'conversion', {
'send_to': 'AW-ID/AWID',
'event_callback': callback
});
return false;
}
</script>
<?php wp_head(); ?>
</head>
<body <?php body_class(); ?>>阅读更多有关如何为您的谷歌广告帐户here调整全局站点标签的信息
https://stackoverflow.com/questions/68993512
复制相似问题