Lesson 14: Tracking of user interaction

From VZ Developer Wiki
Jump to: navigation, search

General Guidelines | XML Specification | Features | Views | JavaScript API | REST API | Tutorials | OAuth

Lesson 13: Promote your Gadget with Invite and Suggest Back to overview Lesson 15: Embed Flash and interact with the OpenSocial API

For the integration of tracking you need to register tracking events in the source code. Currently, the analysis is performed offline through automatically generated reports. There are two kinds of tracking available:

1. click-through tracking to an external website

<a onclick="gadgets.tracking.externalLink('http://www.google.de', this);">Google</a>

This link adds a tracking event for the URL ‘www.google.de’ and opens it in a new browser window.

2. Tracking of user interaction

gadgets.tracking.reportInteraction('submit', 1);

This codes adds an interaction with the label ’submit’ (please review the list of interactions at Gadgets.tracking_(v0.8)#Available_Interactions) with the value ‘1′ to the tracking report.

To use this methods you have to require the tracking feature in your gadget XML:

<Require feature="tracking" />

A nightly generated report of all tracked interactions, installations and uninstallations is available in your gadget sandbox.

Tracking usage outside of your gadget

With these methods it is very easy to track all actions happening inside your gadget. But what about actions outside of your gadget which lead back to your gadget (e.g. invitations, notifications, change of views, installations etc)?

Change of views
When calling the methods gadgets.views.requestNavigateTo and vz.invite.install you can add any number of optional parameters which can be access with gadgets.views.getParams after the redirect. So you can also add any dynamic tracking parameters you need here. Additionally the parameters you pass to vz.invite.install (e.g. vz.invite.install({"param1":"value1","param2":"value2"})) are passed through the whole installation flow (where the PREVIEW views are included) through to the first view the user sees after the installation. Of course you can add these parameters to the URLs manually as well (e.g. /Gadgets/Install/GADGET_ID//JSON_ENCODED_PARAM_OBJECT Gadgets/Install/350//params/{"param1"%3A"abc"%2C"param2"%3A"def"} )
You can add custom parameters to any notification which will be later added als gadgets.views.getParams to the view the user sees after clicking the notification (see Lesson_17:_Send_notifications_to_users)
Source of installation
The installation event you can register for has the source of the installation (gallery, invitation, profile, canvas, group etc) added as a parameter (See Gadgets_XML#ModulePrefs.2FLink)
Embedded gadgets
When generating URLs for embedded gadgets you can add custom parameters to it the same way as calling requestNavigateTo. (See Vz.embed#vz.embed.getEmbedUrl)
Static-Content definitions with the type "rich"
When generating the URL for a rich static-content definition, you can add parameters which will be added as GET parameters to the resulting IFrame URL (See Vz.embed#vz.embed.getStaticContentUrl)
To distinguish between different types of invitations you can add a custom and possibly unique token to this invitation which will be included in the invitation event that will be called after the user invited some of his friends. To track the actual installation after this invitation you can listen to the install event and look at the installation source (invite). (See also Lesson_13:_Promote_your_Gadget_with_Invite_and_Suggest)

  • Lesson 14: Tracking of user interaction