Using Google Analytics for Android component and custom events

Hi -

I'm having an issue using the free Google Analytics for Android component found in the store. I'm trying to generate a custom event and using the .Send method to record. In looking through the docs, I'm not sure how to properly structure the custom event to be sent over to GA.

Anyone have success with this? My code below:

// Setup Google Analytics Easy Tracker
EasyTracker.GetInstance(this).ActivityStart(this); // This does generate a screen event in GA.
GAServiceManager.Instance.SetLocalDispatchPeriod(60);

Dictionary<string, string> customEvent = new Dictionary<string, string>();
customEvent.Add("Category", "Load");
customEvent.Add("Action", "Start");
customEvent.Add("Label", "Started");
customEvent.Add("Value", "123");

EasyTracker.GetInstance(this).Send(customEvent);

Thanks in advance,

Jason

Posts

  • Actually, in checking again, I found the code sample included with the component, this ended up working:

    // Setup Google Analytics Easy Tracker
    EasyTracker.GetInstance(this).ActivityStart(this);
    GAServiceManager.Instance.SetLocalDispatchPeriod(60);
    
    IDictionary<string, string> gaEvent = MapBuilder.CreateEvent("Load", "Start", "Started", new Java.Lang.Long(123)).Build ();
    EasyTracker.GetInstance(this).Send(gaEvent);
    
Sign In or Register to comment.