anyone track clicks inside an element using GA?

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • fris
    Too lazy to set a custom title
    • Aug 2002
    • 55679

    #1

    anyone track clicks inside an element using GA?

    anyone ever thought of tracking clicks inside a div?

    like a video

    <div id="video">
    {embed}
    {textlink}
    </div>

    anyone doing this using GA?

    here is the code for anyone who wants to try it

    Code:
    <!DOCTYPE html>
    <html lang="en">
      <head>
        <meta charset="utf-8">
        <title>test</title>
        <meta name="viewport" content="width=device-width, initial-scale=1.0">
        <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js"></script>
        <script src="jquery.ga.js"></script>
    
        <script>
        jQuery(document).ready(function($){
    	$.ga('UA-XXXXXX-X');
    	$('#video').ga('click', ['_trackEvent', 'Videos', 'Play', 'videoid=197', '0']);
        });
        </script>
      </head>
    
      <body>
    
        <div id="video">
    	{links here}
        </div>
    
      </body>
    </html>
    
    // ga jquery plugin
    
    (function($){
    	var load = false;
    	var queue = new Array();
    	
    	var gaPush = function(){
    		if ((typeof _gaq != undefined) && load){
    			_gaq.push(arguments[0]);
    		} else if (!load) {
    			queue.push(arguments[0]);
    		} else {
    			$.error('_gaq is undefined');
    		}
    	};
    
    	$.ga = function(){
    		if (typeof arguments[0] === 'object'){
    			gaPush(arguments[0]);
    		} else if (typeof arguments[0] === 'string'){
    			var ua = arguments[0];
    			gaPush(['_trackPageview']);
    			$.ajax({type: 'GET', url: ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js', cache: true, dataType: 'script', data: null}).complete(function(){
    				load = true;
    				queue.unshift(['_setAccount', ua]);
    				$.each(queue, function(ind){
    					gaPush(queue[ind]);
    				});
    			});
    		}
    	};
    	
    	$.fn.ga = function(){
    		if (typeof arguments[0] === 'string') {
    			var event = arguments[0];
    			var args = arguments[1];
    			return this.each(function(){
    				var $this = $(this);
    				$this.bind(event + '.ga', function(){
    					gaPush(args);
    				});
    			});
    		} else {
    			return this;
    		}
    	};
    })(jQuery);
    Since 1999: 69 Adult Industry awards for Best Hosting Company and professional excellence.
  • react
    Confirmed User
    • Sep 2003
    • 673

    #2
    Yup, using event tracking for Flash.
    --
    react

    Comment

    • Love Sex
      Confirmed User
      • Nov 2004
      • 1905

      #3
      do you mean like pixel tracking

      Comment

      • fris
        Too lazy to set a custom title
        • Aug 2002
        • 55679

        #4
        Originally posted by Love Sex
        do you mean like pixel tracking
        no i mean click tracking inside an element, say you have a textlink to a tour inside the <div id="video">

        element, it would assign a custom variable for google analytics and track that.
        Since 1999: 69 Adult Industry awards for Best Hosting Company and professional excellence.

        Comment

        Working...