GA多个网站显示'活跃用户'信息在同一视图中

时间:2016-06-10 23:40:02

标签: google-analytics-api

是否可以使用Google AnalyticsAPI在同一视图中显示多个商店的Active Users部分?就这样:

enter image description here 我想隐藏驱动选择的下拉组合框,我希望能够触发正确的事件,只传递UA-12344-1值来加载给定站点的活动用户数。

我试图让这段代码正常工作,但只有当我的GA帐户的下拉组合框中的下拉值发生变化时,它才会触发事件。我想强制在页面加载时触发多个GA事件。

的JavaScript

activeUsersCOM.once('success', function() {
    var element = this.container.firstChild; 
    var timeout;
    this.on('change', function(data) {
      var element = this.container.firstChild;
      var animationClass = data.delta > 0 ? 'is-increasing' : 'is-decreasing';
      element.className += (' ' + animationClass);

      clearTimeout(timeout);
      timeout = setTimeout(function() {
        element.className =
            element.className.replace(/ is-(increasing|decreasing)/g, '');
      }, 3000);
    });
  });

 var viewSelector = new gapi.analytics.ext.ViewSelector2({
      container: 'view-selector-container',
  }).execute(); 

  viewSelector.on('viewChange', function(data) {

    // Start tracking active users for this view.
    activeUsersCOM.set(data).execute(); 
  });

HTML

        <div id="view-selector-container">
                   <div class="ViewSelector2">
                      <div class="ViewSelector2-item">
                         <label>Account</label>    
                         <select class="FormField">
                            <option selected="" value="89859">My GA Account</option> 
                         </select>
                      </div>
                      <div class="ViewSelector2-item">
                         <label>Website</label>    
                         <select class="FormField"> 

                            <option value="UA-819851-1">Site 1</option>
                            <option value="UA-819851-2">Site 2</option>

                   </select>
          </div>
         </div>
</div>

0 个答案:

没有答案