【问题标题】:Load matomo tracking with a javascript function使用 javascript 函数加载 matomo 跟踪
【发布时间】:2019-10-18 21:26:57
【问题描述】:

使用 javascript 函数加载 matomo 跟踪代码,不要设置 cookie。

当调用函数时,应该加载 matomo 跟踪。 <head> 中加载的源脚本有效。 _paq 数组已填充。该函数被调用。但 cookie 没有保存。
PS:使用 Google Analytics 可以正常工作。

var functions_object = {};

functions_object["matomo"] = function () {
    var _paq = _paq || [];
    /* tracker methods like "setCustomDimension" should be called before "trackPageView" */
    _paq.push(['trackPageView']);
    _paq.push(['enableLinkTracking']);
    (function() {
    var u="//www.example.com/matomo/";
    _paq.push(['setTrackerUrl', u+'matomo.php']);
    _paq.push(['setSiteId', '99']);
    var d=document, g=d.createElement('script'), s=d.getElementsByTagName('script')[0];
    g.type='text/javascript'; g.async=true; g.defer=true; g.src=u+'matomo.js'; s.parentNode.insertBefore(g,s);
    })();
};

完整的脚本嵌入在<head>(>1000 行)中。

我在另一个带有 for 循环的函数中调用 functions_object 中的函数。这对所有人都很好,除了matomo。

注释掉(function() {})(); 行无效。

matomo 代码在函数外工作,在脚本中也是空白的,cookies 被保存。

【问题讨论】:

    标签: javascript matomo


    【解决方案1】:

    能否请您报告此错误并提供直接在 Matomo 问题跟踪器中重现的步骤列表?如果您可以重现它,这可能是 Matomo 中的一个问题。谢谢! http://www.github.com/matomo-org/matomo/issues/

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2019-09-22
      • 1970-01-01
      • 2020-10-26
      • 1970-01-01
      • 2018-08-15
      • 1970-01-01
      • 2019-05-11
      相关资源
      最近更新 更多