Saturday, November 5, 2011

Client Event Tracker - Examples & Demo Page

My previous blog post about Client Event Tracker module for Sitecore was rather technical and did not contain real examples. Since it's much better to show something once than say about it many times, I've created Demo Page, where you can see how the module can be used, side by side with simple results view.

There are 3 examples, let's review them briefly.


1. Tracking JavaScript Events


Simple Accordion with resources for developers, marketers, etc. Expanding different content blocks will trigger analytic event using the following code:

                            $(function () {
                                $("#accordion").accordion(
                                {
                                    change: function (event, ui) {
                                        var event = new AnalyticsPageEvent('Client Event', 'Client Event: Area Expanded - ' + ui.newHeader.context.innerText); 
                                        event.trigger();
                                    }
                                });
                            });

2. Tracking downloads from external servers

Try to click "Download podcast" links. New window will be opened and "Download file from Akamai" event will be triggered. The code is as simple as before:
            jQuery(".downloadLink").click(function () {
                var event = new AnalyticsPageEvent('Download file from Akamai', 'Download file from Akamai - ' + jQuery(this).attr('href'));
                event.trigger();
            });

3. Tracking outgoing links


This one is similar to tracking downloads, with minor differences. Just check the code:

            jQuery("#bottomAccordion a:external").click(function () {
                var event = new AnalyticsPageEvent('External Link', 'Area Expanded - ' + jQuery(this).attr('href'));
                event.trigger();
            });

And here's what you will see after a series of clicks:


That's not a complete list of tasks that can be done by using the module, but I hope I've explained the basics. Did you like the module? Here are the next steps:


2 comments: