When you implement InGo, you are essentially running a social medial marketing campaign for your event(s). As an event organizer, you will want to track how this social media marketing campaign performed against other campaigns. Maybe you have implemented InGo widgets in a variety of pages, and in different ways under certain circumstances. Maybe your just doing A/B testing to see how your users best interact with InGo.
Enter Widget Events, Stage Right.
What are Widget Events?
Widget events are notifications that certain activities have occurred within the widget. When events, start and finish rendering, when user's interact with the widgets, how users interact with the widgets.
Not everything causes an event notification to occur, and we'll be continually adding to the activities that generate these notifications. If you have a particular need, create an enhancement request.
How to Listen for Events
Next step is to get your hook into the event notification cycle so that you can be notified when these events occur. If you're familiar with a typical publish-subscribe/subscription-publication/Listener model, you'll be right at home.
Create a script element in your page and make sure the script waits for the page to finish loading before executing. In the script, add a few lines of code to inform the event emitter what javascript callback method to call when the event occurs. This is essentially your subscription.
<script>
var waitForInGo = setInterval(function(){
if (typeof(InGo) != 'undefined') {
InGo.Events.on('social-authorization:started',
function(args) { },
['AMTR3SOAIYCBNFZUL3P2DBL0CFZ1L1T4']); // use your widget ID
clearInterval(waitForInGo);
}
}, 200);
</script>
This script is essentially registering to receive notifications for when a user initiates social-authorization There are a number of ways to formulate your subscription and a number of events you can listen for. Maybe you want to subscribe to all events in one shot, maybe you want to subscribe to all events from any widget on the page. Maybe you want to listen for events of a particular type from only certain widgets. See the full documentation for more details.
Reacting to Events
What you do with the event, once it happens and your method is called is up to you. Essentially in the line above,
function(args) { },
You can put any valid javascript. Let's say for the sake of explanation that you want to inform you Google Analytics dashboard that this event occurred so you can see how many times each of the social networks are used from each of the pages that the widget is on. You might do something like:
function(args) {
_gaq.push(['_trackEvent', 'social-login:' + args.note, args.url]);
}
Here we've used the Google Analytics _gaq.push method to create a _trackEvent call with the information provided to us by the args value of the event. The Google Analytics signature here is:
_trackEvent(category, action, opt_label, opt_value, opt_noninteraction)
In our example the args.note value would carry the name of the social network the user chose to login with (Facebook, LinkedIn, etc). The args.url is also passed to _trackEvent to provide further details about the page the user was on when this event occurred.
Our example uses Google Analytics. You can use whatever analytics or backend system you choose as long as you have some way to call it in a javascript method.
To Learn more, see the documentation.
Measure twice, cut once. Build a great campaign!
Hope you enjoyed this article.