Forums

Skip Navigation LinksHome / Developer Network / Forums / Sitefinity Older Versions (3.x): Developing with Sitefinity > Google analytics not appearing to detect clicks on image rotator

Google analytics not appearing to detect clicks on image rotator

  • Charles avatar

    Posted on Jan 18, 2012 (permalink)

    Hello,
    I have a website (www.xxxx.com) where I can see the in-page analytics. I see that there are clicks on the page in the top menu, bottem contact etc, but there is an image rotator in the middle of the page that doesn't appear to be getting detected. I clicked on this website a few times on that banner but still nothing is coming up. The link that the click launches is a different website (www.yyyy.com).

    Any ideas why there are no clicks showing for the image rotator?
    Charles

    Reply

  • Boyan Barnev Boyan Barnev admin's avatar

    Posted on Jan 21, 2012 (permalink)

    Hi Charles,

    For Google Analytics to be able to track the clicks on your images/links you'll need to add a client-side handler for the click event that will sent the click to GA. What you can do in this case would be to use jQuery and then the document is loaded you can get all <a> or <img> tags which have links to items from libraries using the attribute contains selector. Then you can modify all elements in the collection to add the GA tracking code.
    In the image rotator class you can use jQuery selector  to select all children of your rotator class who have <img> tags and bind them to your click handler. For example:
    $(document).ready(function () {
        $('.Class').find('img').bind('click', function () {
            _gaq.push(['_trackPageview', this.href]);
        });
    });
    The other option is to create an override of the Generic Cotnent control using this blog post and KB article as guidance. Then in the PreRender event you can get all links from the content about to be rendered and apply the same logic, however using server side code.

    Greetings,
    Boyan Barnev
    the Telerik team
    Do you want to have your say in the Sitefinity development roadmap? Do you want to know when a feature you requested is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items

    Reply

Skip Navigation LinksHome / Developer Network / Forums / Sitefinity Older Versions (3.x): Developing with Sitefinity > Google analytics not appearing to detect clicks on image rotator