Written by: Tim Windsor
This is the third follow-up post from the UCOSP program this past fall. In previous terms, we started working on PhoneGap plugins to add BlackBerry 10 support. We started by building new BlackBerry 10 plugins, and then worked on merging them into the existing PhoneGap ones. Tanya, from the University of Alberta, worked on Google Analytics. Here’s her account of the term:
The first step in actually merging the plugin was to add the BB10 platform to the plugin.xml. This was a relatively straightforward task, which I worked on with one of my teammates, as she was also merging a different plugin into the PhoneGap repo.
Below is a description of all the BB10 plugin functions that I merged. Each function takes success and failure handlers as arguments as well as those detailed below.
To use the GA plugin users must first initialize the plugin with the function init() and send the GA account ID as an argument. This will be the property in your GA dashboard where the stats will be sent. Init also requires an argument used to determine the rate at which batches of logged metrics are sent to the GA account.
To log page views a function called trackPage() is used. This function takes as an argument the url of the page you wish to log.
The plugin also allows users to track events using the trackEvent() function. To use this function, it requires the category of the type of event, action, a label to describe the event, and a value whose meaning is up to the user of the plugin.
The function setVariable() sets a custom dimension. For a user to use this function, first they need to configure a custom dimension in their Google Analytics account. In their GA account they must define a custom dimension with an index, name and other properties. Next information is collected by calling the setVariable() function and sending the index defined in the account as an argument, as well as the value for the custom dimension. This information will be sent with the next function call. For example, if you call setVariable() and then trackEvent(), the value for the custom dimension will be sent with trackEvent().
Before exiting the app use exitGA() to check the queue and post any remaining information to the users GA account.
Overall, UCOSP has been a useful course allowing me to gain valuable real world experience. Having the opportunity to contribute to the Blackberry10 PhoneGap project has been insightful and helped me realize the importance of contributing to open source projects.
Since the work Tanya contributed, we’ve continued to work on the plugin and currently have a pull request open with the PhoneGap repo. Besides Google Analytics, she also performed preliminary investigation on the ExternalScreen plugin, which we started work on this term. If you’re interested in following along with the student project, watch #bbucosp on twitter. All of the code will be going into the public BlackBerry repositories on GitHub. If you want to get involved yourself, contact me to get started: @timothywindsor on twitter, https://github.com/timwindsor on GitHub.