nullUK http://null-uk.com Most recent posts at nullUK posterous.com Fri, 27 Apr 2012 12:49:00 -0700 Tracking SublimeVideo plays in Google Analytics http://null-uk.com/tracking-sublimevideo-plays-in-google-analyti http://null-uk.com/tracking-sublimevideo-plays-in-google-analyti

SublimeVideo is an awesome native HTML5 player (with Flash fallback support) from the guys over at Jilion

Logging your plays and stops in Google Analytics is extremely easy thanks to the callbacks provided by SublimeVideo. Just make sure you have a unique data-uid on each video tag

sublimevideo.ready(function() {
    sublimevideo.onStart(function(sv) {
        _gaq.push(['_trackEvent', 'Videos', 'Play', sv.element.getAttribute('data-uid')]);
    });
    sublimevideo.onEnd(function(sv) {
        _gaq.push(['_trackEvent', 'Videos', 'End', sv.element.getAttribute('data-uid')]);
        sublimevideo.stop();
    });
});

Permalink | Leave a comment  »

]]>
http://files.posterous.com/user_profile_pics/1251332/download.jpeg http://posterous.com/users/hesWoDgOl66n0 Leon Smith nulluk Leon Smith
Thu, 02 Jun 2011 13:40:00 -0700 Tracking Magento one page checkout steps using Google Analytics http://null-uk.com/tracking-magento-checkout-steps-using-google http://null-uk.com/tracking-magento-checkout-steps-using-google

If your looking for a way to implement funnel tracking for Magento's one-page checkout then the following solution adapted from here is the implementation that I have used on many of accessions. It involves overriding the accordion function of the onepage, whilst that sounds complicated it's very easy to implement.

First copy the following file

/app/design/frontend/base/default/template/checkout/onepage.phtml

and paste it into your own theme folder which should be located at

/app/design/frontend/default/YOURTHEME/template/checkout/onepage.phtml

After you now have a local copy of the template, open it up and locate the line where the accordion is specified

var accordion = new Accordion('checkoutSteps', '.step-title', true);

After identifying the following line copy the following code before the above identified line but still inside the javascript tag

Checkout.prototype.gotoSection = function(section) {
        try {
                _gaq.push(["_trackPageview", "<?php echo Mage::getSingleton('core/url')->escape($_SERVER['REQUEST_URI']); ?>" + section + "/"]);
        } catch(err) { }
        section = $('opc-'+section);
        section.addClassName('allow');
        this.accordion.openSection(section);
};

So your javascript tag at the bottom of the template should look something along the lines of

<script type="text/javascript">
        Checkout.prototype.gotoSection = function(section) {
                try {
                        _gaq.push(["_trackPageview", "<?php echo Mage::getSingleton('core/url')->escape($_SERVER['REQUEST_URI']); ?>" + section + "/"]);
                } catch(err) { }
                section = $('opc-'+section);
                section.addClassName('allow');
                this.accordion.openSection(section);
        };
        var accordion = new Accordion('checkoutSteps', '.step-title', true);
        <?php if($this->getActiveStep()): ?>
        accordion.openSection('opc-<?php echo $this->getActiveStep() ?>');
        <?php endif ?>
        var checkout = new Checkout(accordion,{
                progress: '<?php echo $this->getUrl('checkout/onepage/progress') ?>',
                review: '<?php echo $this->getUrl('checkout/onepage/review') ?>',
                saveMethod: '<?php echo $this->getUrl('checkout/onepage/saveMethod') ?>',
                failure: '<?php echo $this->getUrl('checkout/cart') ?>'}
        );
</script>

Now finally the last set that you might want to do is set up a goal with the url of /checkout/onepage/success/ and the following Step URLs

  • /checkout/onepage/
  • /checkout/onepage/billing/
  • /checkout/onepage/shipping/
  • /checkout/onepage/shipping_method/
  • /checkout/onepage/payment/
  • /checkout/onepage/review/
  • /checkout/onepage/success/

Any that's how you set up Google Analytics on Magento's one page checkout, if you have any recommendations on anyway to improve this then then please comment and I will update the post accordingly!

Permalink | Leave a comment  »

]]>
http://files.posterous.com/user_profile_pics/1251332/download.jpeg http://posterous.com/users/hesWoDgOl66n0 Leon Smith nulluk Leon Smith
Tue, 31 May 2011 14:45:00 -0700 Twitter Intent Events with Google Analytics using _gaq.push(); http://null-uk.com/55090968 http://null-uk.com/55090968

Update- 2012-04-27: I'v rewrote the original article and brought it up to date. Instead of using _trackEvent it now uses the appropriate _trackSocial call for google analytics.

This is a quick script that i created to enable twitter intent event tracking with google analytics.

It's derived from twitters official intents-events page but wrapped around a jQuery document ready so twitter's script doesn't slow down your page load and also makes sure the twitter javascript is loaded before you bind your own callbacks to track the intents

jQuery(document).ready(function($) {
        $.getScript('//platform.twitter.com/widgets.js', function() {
            function trackSocialIntent(intent_event) {
                if (!intent_event) { return; }
                _gaq.push(['_trackSocial', 'twitter', intent_event.type]);
            }
            twttr.events.bind('click', trackSocialIntent);
            twttr.events.bind('tweet', trackSocialIntent);
            twttr.events.bind('retweet', trackSocialIntent);
            twttr.events.bind('favorite', trackSocialIntent);
            twttr.events.bind('follow', trackSocialIntent);
        });
    });

And thats all there is to it!

Update 2! - 2012-04-27: Why even use jQuery? It's a heavy framework and this vinila JS does the exact same as above but without the jQuery requirement!

(function() {
    window.twttr = (function(d,s,id) {
        var t, js, fjs = d.getElementsByTagName(s)[0];
        if (d.getElementById(id)) return; js=d.createElement(s); js.id=id;
        js.src="//platform.twitter.com/widgets.js"; fjs.parentNode.insertBefore(js, fjs);
        return window.twttr || (t = { _e: [], ready: function(f){ t._e.push(f) } });
    }(document, "script", "twitter-wjs"));

    twttr.ready(function(twttr) {
        function trackSocialIntent(intent_event) {
            if (!intent_event) { return; }
            _gaq.push(['_trackSocial', 'twitter', intent_event.type]);
        }
        twttr.events.bind('click', trackSocialIntent);
        twttr.events.bind('tweet', trackSocialIntent);
        twttr.events.bind('retweet', trackSocialIntent);
        twttr.events.bind('favorite', trackSocialIntent);
        twttr.events.bind('follow', trackSocialIntent);
    });        
})();

Permalink | Leave a comment  »

]]>
http://files.posterous.com/user_profile_pics/1251332/download.jpeg http://posterous.com/users/hesWoDgOl66n0 Leon Smith nulluk Leon Smith