Plugin Directory

Changeset 201072

Timestamp:
02/02/2010 03:12:18 PM (15 years ago)
Author:
ShaneF
Message:

event tracking now working! options for tracking certain items are not yet configurable, but they work in testing

Location:
woopra/trunk
Files:
1 added
4 edited

Legend:

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

    r201033 r201072  
    1111 */
    1212class WoopraAdmin extends Woopra {
    13 
    14     /**
    15      * Current Event
    16      * @since 1.4.1
    17      * @var array
    18      */
    19     var $event;
    20    
    21     /**
    22      * All the events.
    23      * @since 1.4.1
    24      * @var array
    25      */
    26     var $_events;
    27    
    28     /**
    29      * Initlize Test Error Code
    30      * @since 1.5.0
    31      * @var string
    32      */
    33     var $init_error;
    34    
     13       
    3514    /**
    3615     * The plugin file.
     
    11493     * Test to see if we can even initilize
    11594     * @since 1.5.0
    116      * @return boolean
     95     * @return
    11796     */
    11897    function init_test() {
     
    394373            $newopts = array (
    395374                'use_subdomain' =>  0,
     375
    396376                'root_domain'   =>  $this->woopra_host(),
    397377            );
     
    410390    function defaults() {
    411391        $defaults = array(
     392
    412393            'version'           => WOOPRA_VERSION,
    413394            'activated'         => 1,
     395
    414396            'api_key'           => '',
    415397            'analytics_tab'     => 'dashboard',
    416398            'run_status'        => 'on',
    417             'date_format'       => 'yyyy-MM-dd',    // hardcoded for now
     399            'date_format'       => 'yyyy-MM-dd',    //
    418400            'limit'             => 50,
     401
    419402            'auto_tagging'      => 1,
    420403            'ignore_admin'      => 0,
    421404            'track_admin'       => 0,
     405
    422406            'use_timeout'       => 0,
    423407            'use_subdomain'     => 0,
     
    521505        </tr>
    522506        <tr valign="top">
     507
     508
     509
     510
     511
     512
     513
     514
     515
     516
     517
     518
    523519            <th scope="row"><?php _e('Ignore Administrator', 'woopra') ?></th>
    524520            <td>
    525521                <input type="checkbox" value="1"<?php checked('1', $this->get_option('ignore_admin')); ?> id="ignore_admin" name="woopra[ignore_admin]"/> <label for="ignore_admin"><?php _e("Ignore Administrator Visits", 'woopra'); ?></label><br /><?php _e("Enable this check box if you want Woopra to ignore <strong>your visits</strong> or any other administrator visits.", 'woopra'); ?>
    526             </td>
    527         </tr>
    528         <tr valign="top">
    529             <th scope="row"><?php _e('Auto Tagging', 'woopra') ?></th>
    530             <td>
    531                 <input type="checkbox" value="1"<?php checked('1', $this->get_option('auto_tagging')); ?> id="auto_tagging" name="woopra[auto_tagging]"/> <label for="auto_tagging"><?php _e("Automatically Tag Members &amp; Commentators", 'woopra'); ?></label><br /><?php _e("Enable this check box if you want Woopra to auto-tag visitors.", 'woopra'); ?>
    532522            </td>
    533523        </tr>
  • woopra/trunk/inc/frontend.php

    r200971 r201072  
    3838       
    3939        //  Frontend Actions
    40         add_action( 'wp',                       array(&$this, 'woopra_detect')                  );
    41         add_action( 'admin_head',               array(&$this, 'woopra_detect'),             10  );     
    42         add_action( 'wp_footer',                array(&$this, 'woopra_widget'),             10  );
    4340        add_action( 'init',                     array(&$this, 'init')                           );
     41
     42
     43
     44
     45
    4446        if ($this->get_option('track_admin'))
    45             add_action( 'admin_footer',             array(&$this, 'woopra_widget'),         10  );
     47            add_action( 'admin_footer',             array(&$this, 'w            10  );
    4648       
     49
     50
     51
     52
     53
     54
     55
     56
     57
     58
     59
     60
     61
     62
     63
     64
     65
     66
     67
     68
     69
     70
     71
     72
     73
     74
     75
     76
     77
     78
     79
     80
     81
     82
     83
     84
     85
     86
     87
     88
     89
     90
     91
     92
     93
     94
     95
     96
     97
     98
     99
     100
     101
     102
     103
     104
     105
     106
     107
     108
     109
     110
    47111    }
    48112   
     
    52116     * @return boolean
    53117     */
    54     function woopra_status() {
     118    function _status() {
    55119        if ($this->get_option('run_status') == 'on')
    56120            return true;
     
    64128     * @return boolean
    65129     */
    66     function woopra_admin() {
     130    function _admin() {
    67131        if ($this->get_option('ignore_admin'))
    68132            if ($this->woopra_visitor['admin'])
     
    73137            return false;
    74138    }
    75    
    76     function init() {
    77         wp_enqueue_script( 'woopra-tracking',   $this->plugin_url() . '/js/jquery.tracking.js',     array('jquery'), '20100201', true );
    78139       
    79         //  Set jQuery Options
    80         if ( $this->get_option('use_subdomain') )
    81             $this->create_localize( array('rootDomain'      =>  $this->get_option('root_domain') )          );
    82        
    83         if ( $this->get_option('use_timeout') )
    84             $this->create_localize( array('setTimeoutValue' =>  ($this->get_option('timeout')*1000) )       );
    85        
    86         //  For showing in the Woopra Desktop Application
    87         $this->create_localize( array('name'        =>  __('Name'))     );
    88         $this->create_localize( array('email'       =>  __('email'))    );
    89        
    90         //  Output jQuery Options
    91         wp_localize_script( 'woopra-tracking', 'woopraFrontL10n', $this->local );
    92     }
    93    
    94     /**
    95      * Create the localized array string.
    96      * @since 1.5.0
    97      * @param $array
    98      * @return none
    99      */
    100     function create_localize($array) {
    101         $this->local = array_merge($array, $this->local );
    102     }
    103    
    104140    /**
    105141     * Create the Javascript Code at the Bottom
     
    107143     * @return none
    108144     */
    109     function woopra_widget() {
     145    function widget() {
    110146       
    111         if (!$this->woopra_status())
     147        if ()
    112148            return;
    113149       
    114         if ($this->woopra_admin())
    115             return;
    116 
    117150        /*** JQUERY CODE -- DO NOT MODFIY ***/
    118151        echo "\r\n<!-- Woopra Analytics Code -->\r\n";
     
    130163     * @return none
    131164     */
    132     function woopra_detect() {
     165    function detect() {
    133166        $current_user = wp_get_current_user();
    134167       
  • woopra/trunk/js/jquery.tracking.js

    r200971 r201072  
    11/*
    2 * jquery-woopra-analytics plugin
     2* jlugin
    33*
    44* A jQuery plugin that makes it easier to implement Woopra tracking for your site.
    5 * I've ported this from Christian Hellsten's excellent jQuery Google Analytics plugin.
    6 *
    7 * His plugin can be found at http://github.com/christianhellsten/jquery-google-analytics.
    85*
    96* Adds the following methods to jQuery:
     
    1411* See here for more: http://www.woopra.com/docs/customization/
    1512*
    16 *
    1713* Copyright (c) 2009 Pranshu Arya
    18 *
     14* Modifed by Shane <shane@bugssite.org> to work for the WordPress Woopra Plugin
     15*
    1916* Version 1.1
    2017**
     
    2522*   - http://woopra.com
    2623*   - http://github.com/christianhellsten/jquery-google-analytics
    27 *   
    28 * Modifed by Shane <shane@bugssite.org> to work for the WordPress Woopra Plugin
    29 *
     24*   - http://pranshuarya.com/jaal/Development/jquery-woopra-plugin.html
    3025*/
    3126
    3227(function($) {
    3328
    34   /**
    35    * Enables Woopra tracking on the page from which it's called.
    36    *
    37    * Usage:
    38    *
    39    *  <script type="text/javascript">
    40    *    $.trackWoopra();
    41    *  </script>
    42    *
    43    *  -or-
    44    *
    45    *  <script type="text/javascript">
    46    *    $.trackWoopra({domain : 'http://www.mydomain.com', url : 'http://www.myurl.com', title : 'My page', cookie : 'exclude_cookie'});
    47    *  </script>
    48    *
    49    * domain parameter is optional - use it to specify root domain (to track sub-domains)
    50    *
    51    * url and title parameters are optional (but must be passed in together),
    52    * in case you want to give pages custom names in Woopra
    53    *
    54    * use the cookie parameter to exclude visitors, including yourself, based on a cookie
    55    *
    56    */
     29    /**
     30     *
     31     */
    5732    $.trackWoopra = function(woopra_data) {
    5833        var script;
     
    11388        if ( woopraTracker == 'undefined' ) {
    11489            debug('FATAL: woopraTracker is not defined'); // blocked by whatever
    115         }
    116         else if(excludeCookie == 'noCookie') {
     90        } else {
    11791            var w_event = new WoopraEvent(title);
    118            
    11992            // For each property pair passed to woopraEvent, add it to w_event
    12093            $.each(woopra_options, function(i,val){
    12194                w_event.addProperty(i,val);
    122             //  debug('w_event.addProperty(' + i + ', ' + val + ')');
    12395            });
    12496            w_event.fire();
    12597        }
    12698    };
    127 
    128   /**
    129    * Adds click tracking to elements. Usage:
    130    *
    131    *  $('a').trackEvent({title : 'title', var1 : 'value1', var2: 'value2', var3 : 'value3', ..., event_name: 'mouseover'});
    132    *
    133    *  title parameter is required, all others are optional
    134    *  add as many property pairs as you want (as shown above) on your webpage
    135    */
    136   $.fn.trackEvent = function(woopra_options) {
    137 
     99   
     100    $.fn.trackEvent = function(woopra_options) {
     101       
    138102        // Add event handler to all matching elements
    139103        return this.each(function() {
     
    142106         
    143107            // Prevent an element from being tracked multiple times.
    144             if (element.hasClass('w_tracked')) {
     108            if () {
    145109                return false;
    146             }
    147             else {
     110            } else {
    148111                element.addClass('w_tracked');
    149112            }
    150             if(woopra_options){
     113            if{
    151114                // Use default woopra_options, if necessary
    152                 var woop_settings = $.extend({}, $.fn.trackEvent.defaults, woopra_options);
     115                var woop_settings = $.extend({}, $.fn.trackEvent.defaults, woopra_options);
    153116
    154117                // Merge custom woopra_options with defaults.
    155                 var title = evaluate(element, woop_settings.title);
    156                 var event_name = evaluate(element, woop_settings.event_name);
     118                var title = evaluate(element, woop_settings.title);
     119                var event_name = evaluate(element, woop_settings.event_name);
    157120               
    158121                // Iterate over the other property pairs in 'woopra_options'.  Leave them alone if they are
     
    178141                var index = $(parent).find('> *').index(this);
    179142                // Should we skip internal links? REFACTOR
    180                 var skip = woop_settings.skip_internal && (element[0].hostname == location.hostname);
     143                var skip = woop_settings.skip_internal && (element[0].hostname == location.hostname);
    181144                // Get title and other property pair values for item that was clicked
    182145                // and pass them to $.woopraEvent
    183                 if(!skip) {
    184                     var title = evaluate($(parent).children().eq(index), woop_settings.title);
     146                if() {
     147                    var title = evaluate($(parent).children().eq(index), woop_settings.title);
    185148                    options = {}
    186149                    $.each(woopra_options, function(i,val){
     
    188151                    });
    189152                    $.woopraEvent(title, options);
    190                     // Display item that was tracked when event_name was triggered
    191                     if(excludeCookie == 'noCookie'){
    192                         debug('Tracked ' + message);
    193                     }
    194                     else {
    195                         debug('Tracking ' + message + ' skipped due to exclude cookie');
    196                     }
     153                    debug('Tracked ' + message);
    197154                } else {
    198                     if(excludeCookie == 'noCookie'){
    199                         debug('Skipped ' + message);
    200                     }
    201                     else {
    202                         debug('Skipped ' + message + ' due to exclude cookie');
    203                     }
     155                    debug('Skipped ' + message);
    204156                }
    205157                return true;
  • woopra/trunk/woopra.php

    r200971 r201072  
    100100     */
    101101    function get_option($option) {
    102         if (isset($this->options[$option]))
     102        if ()
    103103            return $this->options[$option];
    104104        else
Note: See TracChangeset for help on using the changeset viewer.