-
Notifications
You must be signed in to change notification settings - Fork 110
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
No documentation for setup on ASP.NET Web API #104
Comments
I'll write down few tips on how to set it up |
Thanks, it would nice with information on how to ensure it is properly setup and actually working though. And if this can be verified in testing environment too or only in production environment. |
@vanillajonathan you can create an attribute and decorate all classes you need to track or just create a base class and decorate it. [AttributeUsage(AttributeTargets.Class | AttributeTargets.Method, Inherited = true, AllowMultiple = true)]
public class GoogleAnalyticsTracking : ActionTrackingAttribute
{
public GoogleAnalyticsTracking() : base("UA-XXXXXXXX-Y")
{ }
}
[GoogleAnalyticsTracking]
public class ApiBase : ApiController { } |
Yes, but how and what to do to How to register it globally, or on all /api/* routes. |
Do you have an example to share of the above GoogleAnalyticsTrackingAttribute combined with a custom IAnalyticsSession to track user sessions? I don't know where to start with creating the custom IAnalyticsSession let alone combine it with the api controller attribute. Thanks! |
@vanillajonathan you can set it globally like MVC does. |
@tmulholl you can invoke its base constructor passing Tracker object which naturally accepts an IAnalyticsSession. [AttributeUsage(AttributeTargets.Class | AttributeTargets.Method, Inherited = true, AllowMultiple = true)]
public class GoogleAnalyticsTracking : ActionTrackingAttribute
{
public GoogleAnalyticsTracking()
: base(new Tracker("UA-XXXXXXXX-Y", null, new MyCustomAnalyticsSession(), new AspNetWebApiTrackerEnvironment()))
{
}
} |
How is this going? Has any documentation been written yet? |
What should be inside the "MyCustomAnalyticsSession" class? I am getting this error also. Looks like it takes string, string, string, string.
|
This seems like a really cool project... It's just too bad that I have absolutely no idea how to use it, because there is no documentation. What is an "tracker environment" and how do I create one? How do I track users? How do I send a Goal Event? Tons of potential, just needs documentation! |
With GoogleAnalyticsTracker.WebAPI2 I use the following code to setup a global action tracking filter for all controllers in the /api/ path. public static class WebApiConfig
{
public static void Register(HttpConfiguration config)
{
// Web API configuration and services
// Configure Web API to use only bearer token authentication.
config.SuppressDefaultHostAuthentication();
config.Filters.Add(new HostAuthenticationFilter(OAuthDefaults.AuthenticationType));
config.Filters.Add(new ActionTrackingAttribute(
"UA-XXXXXXX-XX", action => action.ControllerContext.Request.RequestUri.AbsolutePath.StartsWith("/api/")));
}
} |
There is no documentation for how to setup GoogleAnalyticsTracker on ASP.NET Web API.
The text was updated successfully, but these errors were encountered: