There is a difference between the enable...
functions - which configure the tracker options, and the track...
functions, which manually track an event.
All track...
functions can take a context argument, but the enable...
functions can’t (Some of them might be able to, I’m not sure - it’s been a while since I’ve worked on trackers!).
In this instance, enableMediaTracking
switches on the configuration for the tracker to automatically capture media tracking events. It can’t take a context argument the way you have configured.
However, the global context feature that Paul suggested can add contexts to those automatically tracked events.
My suggestion is to experiment with a track...
method first, to get used to how contexts work, and then use the global contexts feature to add contexts to the media events.
It might help if I explain why a bit more explicitly:
In general, using custom contexts (and custom events) requires you to:
- Have an Iglu Server set up to host schemas
- Create a schema for the custom data and upload it to the Iglu Server
- Set up your tracking to refer to that schema
The enrich component then uses the schema to validate the data. This in itself isn’t terribly complicated once you understand how it works - but it’s best to understand this part well as a first step, because debugging is much easier when you’re familiar with it. We typically recommend to use Snowplow Mini, or Snowplow Micro to help with the debugging of schemas and tracking.
I think it’ll be easiest to experiment with this using a simple trackPageView
first - then once you’ve done so, it will be much easier to implement global contexts.
Of course you can go straight to implementing global contexts if you wish, it just might be harder to debug, since you have the complexity of the global context api to deal with on top of the above. (Which is also not hugely complex on its own, but it can get very confusing if you haven’t got to grips with the above concepts first).
I hope that’s helpful!