簡體   English   中英

包含命中類型的 Google Analytics 事件未觸發

[英]Google Analytics Event not firing containing hit type

我有一個計算代碼的小型內部應用程序,我正在嘗試對其進行設置,以便每次有人使用它時 Google Analytics 都會記錄一個事件,但問題是,該事件沒有記錄。 我腦子里有我的谷歌分析標簽,但是當我調用以下函數時:

ga("send", "event", "code", "counted", "Counted Code", jsonReturn.data.raw_total);

一旦我對代碼進行實際計數的 ajax 調用完成,就不會發生任何事情。 Google Analytics 中沒有記錄任何事件。

我究竟做錯了什么?

- - - - - - - - - - - 編輯 - - - - - - - - - - -

這是調用它的周圍代碼:

window.addEventListener("repofound", (ev:CustomEvent) => {

    const repoUrl:string = ev.detail;
    const ajax:XMLHttpRequest = new XMLHttpRequest();
    ajax.open("GET", "https://URLtoServer" + repoUrl);
    ajax.send();
    ajax.onload = () => {

        countButton.removeAttribute("aria-busy");

        const jsonReturn = JSON.parse(ajax.response);

        if (jsonReturn.success) {

            ga("send", "event", "code", "counted", "Counted Code", jsonReturn.data.raw_total);

            // specific client side UI code that is most definitely firing

        }

    };


}, false);

從您的評論中可以明顯看出,您正在使用gtag庫,而事件正在使用ga (Analytics Universal)發送它。

所以你需要從這里編輯你的事件:

ga("send", "event", "code", "counted", "Counted Code", jsonReturn.data.raw_total);

對此:

gtag('event', 'counted', {
  'event_category': 'code',
  'event_label': 'Counted Code',
  'value': jsonReturn.data.raw_total
});

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM