-
Notifications
You must be signed in to change notification settings - Fork 3
Event
Linda Lawton edited this page Jul 1, 2018
·
1 revision
Events are sent when a user interacts with something on your site or app (clicks a button). This is a simple class that will create a hit and send it.
- Event hits can be sent to web and mobile google analytics accounts.
- Event catagory and Event action must be sent.
- Response is always a gif. Google analytics does not notify you of failure. see note below
class EventHitSender
{
public static bool Send(ITracker tracker)
{
var hit = new EventHit("Button", "Click")
{
UserId = "123456"
};
var request = (Hitrequest)tracker.CreateHitRequest(hit);
var collectRequest = Task.Run(() => request.ExecuteCollectAsync());
collectRequest.Wait();
return true;
}
}
Note: Google analytics doesn't actually verify that the it was sent. You will receive a gif back with every hit even if it fails. You should do a debug test on your hits in testing before going to production and sending the actual hits.