matomo-org / matomo-sdk-android

SDK for Android to measure your apps with Matomo. Works on Android phones, tablets, Fire TV sticks, and more!
BSD 3-Clause "New" or "Revised" License
390 stars 162 forks source link

Media Analytics Tracking #232

Open srisheshprabhu opened 5 years ago

srisheshprabhu commented 5 years ago

I am trying to track the media events in the android applications using the media parameters provided. I am not able to find a proper way to do the same. Could not find a Media event function or class. Please let me know how I can achieve the same

d4rken commented 5 years ago

https://matomo.org/docs/event-tracking/

https://github.com/matomo-org/piwik-sdk-android/blob/dca33697d00fc077c90e05352c002cb7df7285bc/piwik-sdk/src/main/java/org/piwik/sdk/extra/TrackHelper.java#L211

srisheshprabhu commented 5 years ago

M sorry, I think I was not clear the first time. Let me rephrase it. I am trying to track a media event with the media parameters. Refer the following link : https://developer.matomo.org/guides/media-analytics/custom-player#media-analytics-http-tracking-api-reference

Also Since you have shown the class to create a event class, please mention how we can send that using tracker, trackme helper or any other method which accepts the Event object.

Thank you in advance.

d4rken commented 5 years ago

M sorry, I think I was not clear the first time. Let me rephrase it. I am trying to track a media event with the media parameters. Refer the following link : https://developer.matomo.org/guides/media-analytics/custom-player#media-analytics-http-tracking-api-reference

There is currently not special class/routine just for this ( I think it should be added though). You'd have to set the parameters manually.

Just create a new TrackMe object and set the parameters on it, then pass it to the tracker instance.

Also Since you have shown the class to create a event class, please mention how we can send that using tracker, trackme helper or any other method which accepts the Event object.

The trackhelper is used like this:

https://github.com/matomo-org/piwik-sdk-android/blob/dca33697d00fc077c90e05352c002cb7df7285bc/exampleapp/src/main/java/com/piwik/demo/DemoActivity.java#L70

It's basically a builder pattern with lots of convenience methods.

SilvanaP commented 4 years ago

Hello, I am currently also trying to integrate media tracking. I bought and installed the plugin on my server. But I am still confused about how to use TrackerHelper and TrackMe class properly. Could you please provide a concrete example where you use TrackerHelper and TrackMe class to log a media progress with the paramaters described here: https://developer.matomo.org/guides/media-analytics/custom-player#media-analytics-http-tracking-api-reference ?

d4rken commented 4 years ago

Previous comments are still valid. :point_up:

SilvanaP commented 4 years ago

@d4rken I thought so and of course I already looked at the Links, but I still don't understand how to create an instance of TrackMe and how to pass it.

The DemoActovity.java class you posted above unfortunately does not have an example of the TrackMe class in use. I guess "TrackMe" stands for "Track Media"? I am already successfully using the TrackerHelper to track Events and Screens, but can't figure out how to create and pass an instance of TrackMe class. I am working in Kotlin btw, but I am also happy with java examples of course.

d4rken commented 4 years ago

The TrackHelper class is a convenience tool to help construct TrackMe objects by offering a builder pattern with sane parameters. The TrackHelper class has no such convenience methods for any media specific events, so you have to build your own.

You can construct any TrackMe object you like:

        TrackMe mediaEvent = new TrackMe();
        mediaEvent.set("some_custom_key", "some_custom_value");
        mediaEvent.set("ma_ti", "Strawberry party.");
        mediaEvent.set("ma_id","myid1234");
        getTracker().track(mediaEvent);

How the parameters have to look for media events (i.e which are mandatory/optional), I don't know, you will have to take that from documentation.

TrackMe stands for "Track Me".

SilvanaP commented 4 years ago

@d4rken Thank you so much! That made everything clear, its working now :)