Plugin Directory

Changeset 201709

Timestamp:
02/04/2010 07:53:40 AM (15 years ago)
Author:
ShaneF
Message:

tracking code is a bit better. does not output the javascript at all if there is to be no tracking in admin.

Location:
woopra/trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • woopra/trunk/inc/frontend.php

    r201175 r201709  
    5656    function init() {
    5757       
     58
     59
     60
     61
     62
     63
     64
     65
    5866        /**
    5967         * WordPress Woopra Event Tracking
     
    6573           
    6674            if ( $this->enabled_event('comments') )
    67                 $this->create_localize( array('trackComments' => 'true', 'trackCommentsTitle' => __('Comment Posted')), 'woopra-events' );
    68                        
     75                $this->create_localize( array('trackComments' => 'true', 'trackCommentsTitle' => __('Comment Posted')), 'woopra-events' );     
    6976               
    7077            if ( is_array($this->local['woopra-events']) )
    7178                wp_enqueue_script( 'woopra-events', $this->plugin_url() . '/js/jquery.events.js',       array('jquery', 'woopra-tracking'), '20100201', true );
     79
    7280            wp_localize_script( 'woopra-events', 'woopraEventsL10n', $this->local['woopra-events'] );
    7381        }       
     
    8391            $this->create_localize( array('setTimeoutValue' =>  ($this->get_option('timeout')*1000) ),  'woopra-tracking'   );
    8492       
    85         $this->create_localize( array('name'        =>  'Name'),    'woopra-tracking'   );
    86         $this->create_localize( array('email'       =>  'email'),   'woopra-tracking'   );
    8793        wp_localize_script( 'woopra-tracking', 'woopraFrontL10n', $this->local['woopra-tracking'] );
    8894       
     
    154160    function widget() {
    155161       
     162
    156163        if ( !$this->get_status() || $this->get_admin() )
     164
     165
     166
     167
    157168            return;
    158169       
  • woopra/trunk/js/jquery.tracking.js

    r201175 r201709  
    11/*
    2 * jQuery Woopra Analytics Plugin
    3 *
    4 * A jQuery plugin that makes it easier to implement Woopra tracking for your site.
     2* jQuery Woopra Analytics Plugin (jquery.tracking.js)
     3*
     4* A jQuery plugin that makes it easier to implement Woopra tracking for your site
     5* and allows you to add your own Woopra Tracking Events to the system to follow.
    56*
    67* Adds the following methods to jQuery:
     
    1213*
    1314* Copyright (c) 2009 Pranshu Arya
    14 * Modified by Shane <shane@bugssite.org> to work for the WordPress Woopra Plugin
     15* Modified by Shane <shane@bugssite.org> to work for
    1516*
    16 * Version 1.2
     17* Version 1.
    1718**
    1819* Licensed under the MIT license:
     
    2425*   - http://pranshuarya.com/jaal/Development/jquery-woopra-plugin.html
    2526*/
    26 
    2727(function($) {
    2828
     
    4646        function _woopra_track() {
    4747            if ( woopraTracker != undefined ) {
    48                 if ( woopraFrontL10n.rootDomain != null ) {
    49                     woopraTracker.setDomain( woopraFrontL10n.rootDomain );
    50                     debug('Woopra Root Domain: ' +  woopraFrontL10n.rootDomain);
     48                if ( typeof woopraFrontL10n != "undefined" ) {
     49                    if ( woopraFrontL10n.rootDomain != null ) {
     50                        woopraTracker.setDomain( woopraFrontL10n.rootDomain );
     51                        debug('Woopra Root Domain: ' +  woopraFrontL10n.rootDomain);
     52                    }
     53                    if ( woopraFrontL10n.setTimeoutValue > 0 ) {
     54                        woopraTracker.setIdleTimeout( woopraFrontL10n.setTimeoutValue );
     55                        debug('Woopra Idle Timeout: ' +  woopraFrontL10n.setTimeoutValue + 'ms');
     56                    }
    5157                }
    52                 if ( woopraFrontL10n.setTimeoutValue > 0 ) {
    53                     woopraTracker.setIdleTimeout( woopraFrontL10n.setTimeoutValue );
    54                     debug('Woopra Idle Timeout: ' +  woopraFrontL10n.setTimeoutValue + 'ms');
     58                //  Only run when we have data.
     59                if ( woopra_data.name != null ) {
     60                    woopraTracker.addVisitorProperty( 'name' , woopra_data.name );
     61                    woopraTracker.addVisitorProperty( 'email' , woopra_data.email );
     62                    woopraTracker.addVisitorProperty( 'avatar', woopra_data.avatar );
    5563                }
    56                 woopraTracker.addVisitorProperty( woopraFrontL10n.name , woopra_data.name );
    57                 woopraTracker.addVisitorProperty( woopraFrontL10n.email , woopra_data.email );
    58                 woopraTracker.addVisitorProperty( 'avatar', woopra_data.avatar );
    5964                woopraTracker.track();
    6065                debug('Woopra is loaded.');
     
    114119    $.fn.trackEvent = function(woopra_options) {
    115120       
    116         /**
    117          *
    118          */
    119121        return this.each( function () {
    120122            var element = $(this);
    121123            var parent = $(element).parent();
    122          
     124       
    123125            // Prevent an element from being tracked multiple times.
    124126            if ( element.hasClass('w_tracked') ) {
     
    179181         */
    180182        function evaluate(element, text_or_function) {
    181             if(typeof text_or_function == 'function') {
     183            if) {
    182184                text_or_function = text_or_function(element);
    183185            }
Note: See TracChangeset for help on using the changeset viewer.