Plugin Directory

Changeset 880002


Ignore:
Timestamp:
03/22/2014 02:15:45 PM (12 years ago)
Author:
hoyce
Message:

Version 1.1.2: Fixed bug in restricted url function and added _setDomainName

Location:
google-analytics-injector/trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • google-analytics-injector/trunk/google-analytics-injector.php

    r822493 r880002  
    55 Description: Google Analytics Injector plugin let you inject Google Analytics tracking code into your website to
    66 collect statistics about your visitors. Just add your tracking code from Google Analytics to start the tracking.
    7  Version: 1.1.1
     7 Version: 1.1.2
    88 Author: Niklas Olsson
    99 Author URI: http://www.geckosolutions.se
     
    4646  if (!current_user_can('edit_posts') && get_option('ua_tracking_code') != "") {
    4747    echo "<!-- Google Analytics Injector from http://www.geckosolutions.se/blog/wordpress-plugins/ -->\n";
    48     echo get_google_analytics_tracking_code(get_option('ua_tracking_code'), get_option('site_restriction_url'));
     48    echo get_google_analytics_tracking_code(get_option('ua_tracking_code'), get_option('site_restriction_url'), get_option('site_domain_url'));
    4949    echo "\n<!-- Google Analytics Injector -->\n";
    5050  }
     
    5959 * @return the tracking code to render.
    6060 */
    61 function get_google_analytics_tracking_code($ua_tracking_code, $site_restriction_url) {
     61function get_google_analytics_tracking_code($ua_tracking_code, $site_restriction_url, $site_domain_url) {
    6262  $google_tracking_code = "<script type='text/javascript'>";
    6363  $google_tracking_code .= "";
     
    6565    $google_tracking_code .= "
    6666    var site = '' + document.location;
    67     if (site.indexOf('".$site_restriction_url."') > -1 ) {
    68     "; 
     67    if(site.indexOf('".$site_restriction_url."') == -1 ) {";
    6968  }
    7069  $google_tracking_code .= "
    7170    var _gaq = _gaq || [];
    72     _gaq.push(['_setAccount', '".$ua_tracking_code."']);
    73     _gaq.push(['_trackPageview']);
    74  
     71    _gaq.push(['_setAccount', '".$ua_tracking_code."']);";
     72    if($site_domain_url) {
     73        $google_tracking_code .= "_gaq.push(['_setDomainName', '".$site_domain_url."']);";
     74    }
     75    $google_tracking_code .= "_gaq.push(['_trackPageview']);
    7576    (function() {
    7677        var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
     
    127128          ?>
    128129          <input type="text" name="ua_tracking_code" id="ua_tracking_code" value="<?php echo get_option('ua_tracking_code'); ?>" style="width:400px;"/>
    129          
     130
     131          <h4 style="margin-bottom: 0px;"><?php echo __('Your domain eg. .mydomain.com', 'google-analytics-injector'); ?></h4>
     132          <input type="text" name="site_domain_url" id="site_domain_url" value="<?php echo get_option('site_domain_url'); ?>" />
     133
    130134          <h4 style="margin-bottom: 0px;"><?php echo __('Restrict tracking to this domain http://', 'google-analytics-injector'); ?></h4>
    131135          <input type="text" name="site_restriction_url" id="site_restriction_url" value="<?php echo get_option('site_restriction_url'); ?>" style="width:400px;"/>
     
    175179    $errors = new WP_Error('tracking_code', __('The tracking code is on the wrong format', 'google-analytics-injector'));
    176180  }
    177  
     181
     182  if(isset($_POST['site_domain_url'])) {
     183    update_option('site_domain_url', $_POST['site_domain_url']);
     184  }
     185
    178186  if(isset($_POST['site_restriction_url'])) {
    179187    update_option('site_restriction_url', $_POST['site_restriction_url']);
  • google-analytics-injector/trunk/readme.txt

    r822493 r880002  
    55Tags: google, google analytics, analytics, statistics, stats, javascript, web analytics,
    66Requires at least: 3.0
    7 Tested up to: 3.8
    8 Stable tag: 1.1.1
     7Tested up to: 3.8.1
     8Stable tag: 1.1.2
    99
    1010== Description ==
     
    4646* The plugin now exclude the visits from the Administrator. (bug fix)
    4747* Tested stability up to Wordpress 3.8
     48
     49= 1.1.2 =
     50* Added option for _setDomainName
     51* The plugin now exclude the visits from given restricted url. (bug fix)
     52* Tested stability up to Wordpress 3.8.1
Note: See TracChangeset for help on using the changeset viewer.