与Google Analytics分析联系表格7-gtag事件跟踪目标

问题描述

我正在尝试使用Google Analytics(分析)中的联系表7设置事件跟踪。 Google Tag Assistant似乎看到了该事件,但bot似乎在Google Analytics(分析)中进行了跟踪。请看下面:

document.addEventListener('wpcf7mailsent',function(event) {
    gtag('config','UA-********-*',{
        'send_page_view': false
    });
    // https://developers.google.com/gtagjs/reference/api#event
    gtag('event','form_submitted',{
        'event_category': 'lead','event_action': 'Submit','event_action': 'Form','event_value': 1,});
    console.log('Form Submitted');
},false);

目标设置

enter image description here

Google Tag Assist

enter image description here

解决方法

事件代码中有几个错误(例如,您两次编写了动作),但是构造错误,因为在gtag中发送事件的语法如下:

gtag('event',<action>,{
  'event_category': <category>,'event_label': <label>,'value': <value>
});

https://developers.google.com/analytics/devguides/collection/gtagjs/events

所以您必须像这样更改代码:

gtag('event','Submit',{
    'event_category': 'form_submitted','event_label': 'Form','value': 1
});