-3

My customer wants to track backend user's activity using google-analytics. He wants me to insert UserId in every URL of the backend. Backend is ASP.NET MVC3 and I tried to use routing for this purpose but without any luck.

I thought about more intellegent way to satisfy his need. So I'm thinking about calling google-analytics api from the server-side.

Is there an ability to do all that ga.js does but from c#?

Updated: Customer wants to track user's activity using Google Analytics. He wants me to add ?userId= to all links in backend. So if I had /Category/Edit/123 now I have to change it to /Category/Edit/123?userId=456 Then I put ga.js to every page and customer tracks user's (456) activity.

I find the idea of using Google Analytics this way sucks but I have to implement some solution. The only thing I want is not to change urls but act with Google Analytics API from the server side.

4

1 回答 1

1

好的。这是我认为我真正需要的:

1) 在 Google Analytics(分析)控制台管理中创建 Custim 维度 -> 自定义定义 -> 自定义维度 -> 新自定义维度 -> userId

2) 修改我的 Google Analytics javascript 并插入

var userId = @User.Id;
ga('set', 'dimension1', userId);

在 ga("send", "pageview");

或者

使用此解决方案

https://developers.google.com/analytics/devguides/collection/analyticsjs/user-id?hl=en

于 2013-11-11T10:57:38.770 回答