代码之家  ›  专栏  ›  技术社区  ›  GhitaB

包括自定义尺寸的曲目下载

  •  0
  • GhitaB  · 技术社区  · 6 年前

    在谷歌分析中,我有:

    • 3个自定义维度(用于存储有关已保存用户帐户/首选项的信息的维度1、维度2、维度3)

    我的代码是这样的:

    function track_download(data) {
        var GA = window.ga || function() {
            // ga is not defined, log function arguments
            if (window.console) {
                console.log([].slice.call(arguments));
            }
        };
    
        // Custom dimensions
        GA('set', 'dimension1', data.some_profile_information1);
        GA('set', 'dimension2', data.some_profile_information2);
        GA('set', 'dimension3', data.some_profile_information3);
    
        // Track event
        GA('send', {
            'hitType': 'event', // Required.
            'eventCategory': 'page', // Required.
            'eventAction': 'custom_download', // Required.
            'eventLabel': data.the_title_of_downloaded_section,
            'eventValue': 1
        });
    };
    

    在Google Analytics中,我可以定制如下报告:

    • 最活跃的下载部分

    在马托莫有没有可能 custom dimensions 为了拥有相同的报告/行为而使用自定义事件?

    更新:

    像这样尝试,在自定义维度的报告中没有数据。

    var MA = window._paq || function() {
      // Matomo is not defined, log function arguments
      if (window.console) {
        console.log([].slice.call(arguments));
      }
    };
    
    MA.push([
      'trackEvent',
      'page',               // category
      'my_custom_download', // action
      data.item_title,      // name
      1,                    // value
      {                     // custom dimensions
        dimension1: data.dim1,
        dimension2: data.dim2,
        dimension3: data.dim3
      }
    ]);
    

    这是从 docs : _paq.push(['trackEvent', category, action, name, value, {dimension1: 'DimensionValue'}]);

    1 回复  |  直到 6 年前
        1
  •  1
  •   Ionică Bizău    6 年前

    您提到的解决方案应该有效,但可能会出现延迟(例如,大约一小时):

    var MA = window._paq || function() {
      // Matomo is not defined, log function arguments
      if (window.console) {
        console.log([].slice.call(arguments));
      }
    };
    
    MA.push([
      'trackEvent',
      'page',               // category
      'my_custom_download', // action
      data.item_title,      // name
      1,                    // value
      {                     // custom dimensions
        dimension1: data.dim1,
        dimension2: data.dim2,
        dimension3: data.dim3
      }
    ]);