-
Notifications
You must be signed in to change notification settings - Fork 0
NowSpots api
Tracking events is important! You can use the Nowspots Tracking API to track events and in fact, you almost have to if you want to see any useful analytics in the spot details page. You can find the javascript at: http://www.nowspots.com/api/tracking.js
There are three methods that help you track events:
NowspotsTracker.track(event_name, json_data)
NowspotsTracker.track_click(event_name, json_data, prevent_click_through=false)
NowspotsTracker.prevent_click_through()
Self explanatory? Let's talk about 'em.
track(event_name, json_data) does just what you'd think. Provide the name of the event and if the event name is defined in the json provided by the "events url" defined in the spot_app_template page, then the aggregate number for this event will show up in the spot detail page. json_data can be any json data you'd like, but currently -- although the data is stored in the reporting system -- nowspots.com does not provide a way to act upon the data provided as json to the tracking api.
track_click(event_name, json_data, prevent_click_through=false) behaves the same as track but with the added functionality of optionally preventing a click through. The Nowspots Tracking API captures all of the user's clicks for the app, and at the same time uses the value provided by the destination_url parameter in the query string to open a new window/tab for the user. When this occurs, the api tracks this as a 'click through'. Both the 'click through' event and the associated opening of the destination_url in a new window/tab can be prevented by passing in true as the final argument to the track_click method.
NowspotsTracker.prevent_click_through() is useful when it doesn't make sense for the app to record its own click event, but also the app would like to prevent the behavior described for the track_click method.
The Nowspots Tracking API uses the spot and app parameters provided by the query string to associate all the events it records with the given spot and app. The preview parameter in the query string is used to turn off event tracking, but all the events are still written to the console to make it easy to test app functionality. The api uses the destination_url as described above.