0

我在扫雪机与我的角度应用程序的相互关系中遇到问题我从这里关注官方文档在此处输入链接描述

我的代码是

    <script type="text/javascript">

    ;(function(p,l,o,w,i,n,g){if(!p[i]){p.GlobalSnowplowNamespace=p.GlobalSnowplowNamespace||[];
p.GlobalSnowplowNamespace.push(i);p[i]=function(){(p[i].q=p[i].q||[]).push(arguments)
};p[i].q=p[i].q||[];n=l.createElement(o);g=l.getElementsByTagName(o)[0];n.async=1;
n.src=w;g.parentNode.insertBefore(n,g)}}(window,document,"script","http://d1fc8wv8zag5ca.cloudfront.net/2.6.1/sp.js","snowplow_tracker"));

      console.debug(snowplow_tracker);

    snowplow_tracker('gotoTrackerMethode', '{{MY-COLLECTOR-URI (cloudFront URl)}}');
    function gotoTrackerMethode(a, b)
    {
        console.debug(a);
    }
    function gotoTrackerName(s){
      console.debug("asdf");
    }
    // window.snowplow_tracker('enableActivityTracking', 30, 10);
    // window.snowplow_tracker('enableLinkClickTracking');
    // window.snowplow_tracker('trackPageView');
    </script>

任何帮助将不胜感激。

4

1 回答 1

0

经过大量研发后,我自己找到了解决方案,即您需要调用回调方法不是简单的,而是像回调一样

 ;(function(p,l,o,w,i,n,g){if(!p[i]){p.GlobalSnowplowNamespace=p.GlobalSnowplowNamespace||[];
p.GlobalSnowplowNamespace.push(i);p[i]=function(){(p[i].q=p[i].q||[]).push(arguments)
};p[i].q=p[i].q||[];n=l.createElement(o);g=l.getElementsByTagName(o)[0];n.async=1;
n.src=w;g.parentNode.insertBefore(n,g)}}(window,document,"script","http://d1fc8wv8zag5ca.cloudfront.net/2.6.1/sp.js","snowplow_tracker"));


    // callbacks
  snowplow_tracker(function () {
    console.log("sp.js has loaded");
  });

  snowplow_tracker(function (x) {
    console.log(x);
  }, "sp.js has loaded");


  //Find the utma cookie and extract the unique user ID
  function getGoogleId() {
      var id, a, c = document.cookie.split('; ');
      for (var i in c) {
          a = c[i].split('=');
          if (a[0]==='__utma') {
              id = a[1].split('.')[1];
          }
      }
      return id || 'unknown';
  }


        // Configure a tracker instance named "cf"
  snowplow_tracker('newTracker', 'cf', 'd3rkrsqld9gmqf.cloudfront.net', {
      appId: 'snowplowExampleApp',
      platform: 'web'
  });

  // Access the tracker instance inside a callback
  snowplow_tracker(function () {
      var cf = this.cf;
      var userFingerprint = cf.getUserFingerprint();
       var domainUserId = cf.getDomainUserId();
       var domainUserInfo = cf.getDomainUserInfo();
       var userId = cf.getUserId();
      console.debug(userId);
      console.debug(domainUserInfo);
      console.debug(userFingerprint);
      console.debug(domainUserId);
  })

   snowplow_tracker('enableActivityTracking', 30, 10);
  snowplow_tracker('enableLinkClickTracking');
  snowplow_tracker('trackPageView');

现在工作正常。

于 2016-05-27T10:09:57.187 回答