i am trying wrap my head around how to track some custom user activity. Things like button clicked or any html element clicked. i need to send in a bunch of custom data along with it. I would also like all these events to have all the info about the client as possible… like user agent etc. The way I see it, there are 2 ways to do this.
1 - call the updatePageActivity manually and attach with it the business data as custom contexts. The client/useragent info should come with when i set the webpage:true in argmap during tracker initilization.
2 - call the trackSelfDescribingEvent with the business data.
Question re: solution 1 -
How can i send custom context data with updatePageActivity event? It doesn’t seem to be on the method definition
Question re: solution 2 -
Will trackSelfDescribingEvent bring with it client/useragent info if i set it in argmap during initializtion?
Can i also send custom contexts here if i want to reuse a subset schema across events?
Your best bet here is option 2. You can call trackSelfDescribingEvent and UserAgent information will be automatically sent with the request. Setting the webpage context to true will add a UUID that will allow you to track seperate page views with each event (Events sent on the same page view will all have the same Page View ID).
You can append them when sending the event by adding an extra function parameter containing an array of contexts:
Or if you wish to add a set of custom contexts that are tracked along with ALL events, you can add global contexts. These will be sent with every event but you can also append additional contexts using the method I described above and both sets of custom contexts will be sent. An example of setting global contexts: