谷歌Analytics(分析)如何通过搜索键

问题描述:

我使用NG-repreat显示了一些关于我的网站的职位,我也允许用户过滤器的职位在任何搜索短语键控跟踪与角过滤搜索词在搜索输入框。它工作正常,但我不知道如何使用谷歌分析来跟踪用户正在搜索什么,因为搜索字词不反映在我的网址。 (即URL是仍然是域名/#!/内容,而不是更改为域名/#!/内容?Q = .... + ...)。谷歌Analytics(分析)如何通过搜索键

不知道如何解决这个问题。真的很感谢你能否指点我一些资源。谢谢。

这是我的代码

<input ng-model="vm.searchKey" type="text" placeholder = "Search..." /> 
<div class="card" ng-repeat="post in vm.posts | filter: vm.searchKey"> 
    <a ng-href="#!/post/{{lifePost.post_id}}"> 
     <img class="card-img" src="{{post.img_url}}"> 
     <div class="card-img-overlay"> 
      <p class="card-text">{{post.tagline_grp}}</p> 
      <h4 class="card-title">{{post.post_title}}</h4> 
      <p class="card-text">{{post.post_excerpt}}</p>   
     </div> 
    </a> 
</div> 
+0

我弄清楚,我可以使用NG-变化做后1S '' and in my controller,send GA用户输入的词语以实现我想要的 'v m.trackSearchKey = function(){ if(vm.searchKey){0,'''''','/'q ='+ vm.searchKey); \t ga('send','pageview'); } } ' – Emily

我想出如何使网站的搜索追踪GA做到这一点的简化版本,检测改变事件当在搜索键用户密钥和发送虚拟网页浏览过度。

HTML代码

<input ng-model="vm.searchKey" ng-model-options='{ debounce: 1000 }' ng-change='vm.trackSearchKey()' type="text" placeholder = "Search..." /> 
<div class="card" ng-repeat="post in vm.posts | filter: vm.searchKey"> 
    <a ng-href="#!/post/{{lifePost.post_id}}"> 
     <img class="card-img" src="{{post.img_url}}"> 
     <div class="card-img-overlay"> 
      <p class="card-text">{{post.tagline_grp}}</p> 
      <h4 class="card-title">{{post.post_title}}</h4> 
      <p class="card-text">{{post.post_excerpt}}</p>   
     </div> 
    </a> 
</div> 

JS代码

vm.trackSearchKey = function() { 
    if (vm.searchKey) { 
     ga('set', 'page', '/?q='+vm.searchKey); 
     ga('send', 'pageview'); 
    } 
}