Local Analytics v1.2.2

January 12th, 2008 Leave a comment Go to comments

Local Analytics is a Wordpress plugin for integrating Google Analytics, the free web analysis service by Google, into your Word Press powered blog.  The plugin is highly configurable and also allows caching of the urchin.js ga.js file locally, inorder to enable faster loading of pages. The plugin is based on my PHP program for speeding up Google Analytics by hosting it locally.

The plugin is highly configurable, yet simple. A normal user only needs to specify his / her Analytics UID, while advanced users can completely configure the behavior of the plugin.

Features

  • Highly configurable
  • Compatible with latest Google Analytics Code Update [NEW]
  • Supports local caching of urchin.js for fast loading of pages.
  • Supports compression of the local javascript files using mod_gzip.
  • Includes support for tracking Adsense and YPN ad clicks [NEW]
  • Includes support for tracking email links, external links and file downloads.
  • Includes support for tracking subdomains and main domain in a single profile.
  • Includes support for tracking visits to Admin Panels.
  • Includes support for tracking logged in users.
  • Includes uninstaller for complete removal of the plugin (I’m sure that you won’t be using it :) ).

Advantages of Caching

  • Webpage loads faster, since user’s browser can use the existing connection with your web server to download the file and doesn’t need to create a new connection to Google’s server.
  • Sometimes, though very rarely, google servers become overloaded and your page load time will be affected drastically.
  • Some ad blockers are now blocking tracking services like Google Analytics. This script will be a work around to that too.

Screenshot

Here is a screenshot of the Options page  of the plugin.

[Screenshot] Local-Analytics

Requirements

Installation

  1. Download, unzip & upload the plugin to your ‘/wp-content/plugins/’ directory.
  2. Activate the plugin through the ‘Plugins’ menu in WordPress.
  3. On plugin activation, it will automatically try to create  a file named local-urchin.js in the plugin directory. If it fails, you will see a notification message in the Admin Panel. In that case you will have to manually create the file and chmod it 666.
  4. Go to Options > Local Analytics and enter your Google Analytics UID and hit the Save Options button.

Upgrade

I recommend uninstalling the current plugin (using the uninstall button in Options > Local Analytics) and installing the new version.

Download

Current stable version of the plugin is v1.2.2.

You can download the plugin from the WordPress Plugin Repository.

Frequently Asked Questions

  1. Q. Google Analytics says that the code is not installed correctly. Is something wrong?
    A. Check whether you are seeing any error message in your Admin Panel. If so, fix it. Else ensure that Disable Local Analytics tracking option is unchecked in the Options page.
  2. Q. I am getting the following error in my pages. What should I do?
    Warning: eregi(): REG_EMPTY in /private/path/replaceforprivacy/wp-content/plugins/local-analytics/local-analytics.php on line 127
    A. Using the plugin in non www domains caused the warning in pre 1.12 versions. Please upgrade to the latest version. You have to uninstall the current plugin before upgrading. Alternatively, you may edit the Internal Domains field to fix the error.
  3. Q. I installed the plugin successfully. But I am getting the following error in my Admin Panel
    local-urchin.js does not exist. Please create it.
    A. The plugin automatically downloads and stores a fresh copy of urchin.js ga.js in the plugin directory, under the filename local-urchin.js. While activating the Local Analytics, if there are sufficient privilages, the plugin will automatically create the file. If it fails, then you will have to manually create the file and chmod it 0666. The best idea is to chmod the plugin directory 0666, before activating the plugin (so that the file will be created automatically on plugin activation).
  4. Q. I installed the plugin successfully. But I am getting the following error in my Admin Panel
    local-urchin.js is not writable. Please chmod it 666.
    A. See FAQ entry #4.
  5. Q. How can I chmod a file?
    Q. How can I change file permissions?

    A. You can chmod / change file permission using your FTP client. But the steps are different for different FTP programs. In most FTP clients, you can chmod a file by choosing the option Properties  from the right click context menu.  Also checkout this article by Stadtaus.com on changing file permission in 5 popular FTP clients.
  6. Q. Will Local Analytics integrate the Google Analytics reports within the WordPress Administration Panel?
    A. It is not possible with Local Analytics. But David Szpuner had pointed out an excellent plugin called Wordpress Reports by TanTan, which allows you to integrate your Google Analytics and FeedBurner stats within your Admin Panel.
  7. Q. How can I check whether the plugin is installed correctly or not?
    A. After activating the plugin, visit your blog and check the source of the page for the Local Analytics code. A sample code is given below.
    <!– Begin Google Analytics Code by Local Analytics Plugin –>
    <script type='text/javascript' src='http://www.domain.com/wp-content/plugins/local-analytics/local-urchin-js.php?ver=1.0′></script>
    <script type='text/javascript'>
    _uacct = "UA-XXXXXXX-X";
    urchinTracker();
    </script>
    <!– End Google Analytics Code by Local Analytics Plugin –>

    <!-- Begin Google Analytics Code by Local Analytics Plugin -->
    <script type='text/javascript' src='http://www.domain.com/wp-content/plugins/local-analytics/local-urchin-js.php?ver=1.0'></script>
    <script type="text/javascript">
    var pageTracker = _gat._getTracker("UA-XXXXXX-X");
    pageTracker._initData();
    pageTracker._trackPageview();
    </script>
    <!-- End Google Analytics Code by Local Analytics Plugin -->
  8. Q. I have activated the plugin. But I can’t find the Local Analytics code in my page source. What is the problem?
    A. First of all, ensure that the plugin is installed and configured correctly. If it not configured correctly, then you will see a notifcation message in your WordPress Admin Panel.
    If it is configured correctly, then ensure that the option “Disable Local Analytics tracking” is disabled and logout of your WordPress account, refresh your blog’s homepage (use CTRL + F5 to ensure that the page was not loaded from your browser cache) and check for the Local Analytics code in your page source.
    Please keep in mind that when you are logged in, your visits will be tracked only if you have enabled the “Track Users” option and have appropriate value set for the option “Max. Tracked User Level “.
  9. Q. I have another question that is related / not related to Local Analytics. What should I do?
    Q. My question is not answered above. What should I do?

    A. Either post your question as a comment below or contact me. I will try my best to help you solve it.

ChangeLog

  • v1.2.2
    • Changed relative reference to astrack.js with absolute reference to make the plugin compatible with blogs with different site and wordpress location.
  • v1.2.1
    • Minor update. Fixed a mistake in gzip compression, as pointed out by Sergey Biryukov
  • v1.2
    • Updated the plugin to make it compatible with latest Google Analytics code update
    • Added Adsense and YPN click tracking
  • v1.1.3
    • Fixed a minor error which caused a Bad arguments  warning when the Internal Domains field was left empty.
  • v1.1.2
    • Fixed an error which caused a REG_EMPTY warning in non www domains
  • v 1.1.1
    • Corrected a typo in error message
  • v 1.1
    • Fixed the error pointed out by Kevin
    • Removed the onclick events from RSS feed
    • Dropped domain name from tracked downloads
    • Edited admin panel to display configuration errors
  1. January 12th, 2008 at 03:29 | #1

    Can you tell me the address of the blog where you installed the plugin? Did you try visiting the file directly ie, http://www.youdomain.com/wp-content/plugins/local-analytics/local-urchin.js.

  2. January 13th, 2008 at 08:18 | #2

    Hey Joyce,

    Your plugin it seems very useful, I followed the instructions that was provided. I created the local-urchin.js file(I was supposed to put my code that was provided by Google Analytics in here, right?) then I got this error on my pages:

    Warning: parse_url(http://) [function.parse-url]: Unable to parse URL in /home/getbleac/public_html/wp-content/plugins/local-analytics/local-analytics.php on line 123

  3. Joe
    January 14th, 2008 at 22:07 | #3

    Nice sounding plugin. I have a small problem. Install went ok, the code is in the header of my pages, I have the local-urchin.js CHMODed to 666, and have no errors in the console.

    The problem I have, is that I had to manually crate local-urchin.js. I just made a blank file and uploaded it. After saving all my preferences, local-urchin.js is still at 0kb.

    At what point is ga.js downloaded and renamed to local-urchin.js? Should it have happend right away? or do I have to wait for a cron?

    Thanks!!

  4. Joe
    January 14th, 2008 at 22:41 | #4

    On another note, while the code is visible in the head of each page, GA is giving me the following error:

    The Google Analytics tracking code has not been detected on your website’s home page.

    Weird!

  5. Alex
    January 20th, 2008 at 15:09 | #5

    Hi Joyce, very good plugin!

    But I have a problem when using “Additional Tracking Code”. My WP-blog is on a subdomain. I the tracking of the blog to show the prefix of my subdomain. So I added the code pageTracker._setDomainName(”subdomain.domain.com”);
    I get no stats with the prefix “subdomain.domain.com”. Then I noticed that backslashes are added to the code: pageTracker._setDomainName(\”carl.awake.nu\”);
    Is this the problem? Or is it in order?
    Otherwise I’m pretty sure I have set up google filter options correctly to show the subdomain stats different from the main domain.

  6. January 23rd, 2008 at 13:42 | #6

    Hi Joyce — I have a similar problem to another user above, who seemed to have fixed it without your help but he didn’t post what solved the problem.

    I’m running Wordpress 2.3.2 (latest version) and Local Analytics 1.2.2. It installed ok, I created my own local-urchin.js file, and the analytics script is imbedded (when I view the source).

    My problem: I can’t get google analytics to recognize the code… weird… any ideas?

    Thanks!

    Jonn

  7. Paul
    January 23rd, 2008 at 21:37 | #7

    When I activated this plugin, it created a “local-urchin.js” file that is 0KB in size. There is no analytics code when I view source.

    I have gone through all FAQs, verified that there are no error messages in the admin panel, etc. I can’t figure out what the problem is. Please help.

  8. February 8th, 2008 at 00:33 | #8

    I have the exact same problem. Not sure what to do about it. Anyone else?

  9. February 9th, 2008 at 01:15 | #9

    Hi Joyce

    i like the look of your plugin but unfirtunately it doesn’t accept my google analytics ID – every time i attempt to save it it doesn’t do anything and then when i refresh the browser it says i still need to enter my analytics ID – is there a way I can hard code it in your code to skip the buggy plugin config page – been looking just haven’t found the right spot as yet?
    thanks in advance
    Nick
    ps latest wordpress and also plugin

  10. February 9th, 2008 at 01:18 | #10

    hi joyce

    on latest wordpress and your plugin version and i like the potential your plugin has but the config page is buggy and will not accept my google analytics ID. Can u hard code it somewhere and if so where so i can skip the buggy plugin config screen thanks nick

  11. February 19th, 2008 at 03:33 | #11

    Hello Joyce,

    I have downloaded the latest version of your plugin and am running the latest version of wordpress.

    I uploaded the plugin, activated it and added my tracker ID from google analytics.

    The plugin created a 0kb file named local-urchin.js and google analytics wont pick up on the site.

    Regards,
    Kevin.

  12. February 24th, 2008 at 21:54 | #12

    Joyce, thank you for this great plugin! I’ve been using it for a month, and just today I see this error (using WP 2.3.3 and K2 theme):
    Warning: parse_url(http://) [function.parse-url]: Unable to parse URL in /home/[my directory]/public_html/blog/wp-content/plugins/local-analytics/local-analytics.php on line 123.

    Line 123:
    $url = parse_url($url);

    The URL for the page on which it appears is http://www.coreknowledge.org/blog/

    but http://www.coreknowledge.org/blog/index.php is OK.

    I’ve never seen this problem before today, and there have been no changes to the website, other than a Wordpress update from 2.3.2 to 2.3.3.

    Ideas? For now I’ve disabled the stats.

    —Diana

  13. February 25th, 2008 at 19:39 | #13

    I found that you have to disregard Google’s instructions, and do *not* include http:// in your URL. That solved the problem for me. This goes for all Google Analytics configuration.

  14. February 25th, 2008 at 20:10 | #14

    Maybe we need some code in function locan_parse_link to cope with the missing index.php? I’d rather not add a rewrite mod to .htaccess to force index.php, that might cause other problems. It’s odd that this worked fine for so long, and then failed. Something about the server configuration perhaps? I’m on shared hosting, so who knows! Just need a little patch perhaps?

  15. February 25th, 2008 at 20:43 | #15

    more information: PHP 5.2.5.
    this code:
    $url = 'http://www.coreknowledge.org/blog/';
    print_r(parse_url($url));
    echo parse_url($url);

    renders
    Array ( [scheme] => http [host] => http://www.coreknowledge.org [path] => /blog/ ) Array

  16. February 26th, 2008 at 00:06 | #16

    OK, I hope this helps someone else!

    Check if your wp-config.php has extra linefeeds after the closing bracket, and remove them.

    It messes up the loading order of scripts for the page. It was affecting my tinyMCE visual editor once, and now I find it was affecting this parse_url as well.

    Fantastico will insert extra linefeeds in wp-config.php if you use it to update.

    —Diana

  17. April 1st, 2008 at 12:59 | #17

    Hi Joyce,

    Local Analytics does not support Wordpress 2.5, it crashes on activation. When can the community expect an updated version of this great plugin.

    We <3 Local Analytics :)

  18. Chris
    April 8th, 2008 at 13:17 | #18

    Yes, indeed, it does not work with Wordpress 2.5 :-(

  19. April 9th, 2008 at 19:14 | #19

    Oddly, the problem has returned, with no changes to the blog code, and does not seem to have any relationship to whether the URL contains index.php or not. I deactivated and reactivated the plugin, and the problem disappeared. Weird.

  20. April 24th, 2008 at 22:49 | #20

    Love the plugin.

  21. June 12th, 2009 at 05:46 | #21

    Hi Joyce – I have uninstalled your plugin, but it has left some code in my template, which is generating javascript errors. I am new to wordpress.

    Would you mind emailing me about how to remove this bit of script from my site?

    <!–
    google_ad_client = “pub-0909510381367095″;
    /* 336×280, created 4/13/08 */
    google_ad_slot = “7189509193″;
    google_ad_width = 336;
    google_ad_height = 280;
    //–>

  22. June 12th, 2009 at 10:32 | #22

    Hello Derek

    Derek Martin :

    Hi Joyce – I have uninstalled your plugin, but it has left some code in my template, which is generating javascript errors. I am new to wordpress.

    Would you mind emailing me about how to remove this bit of script from my site?

    <!–
    google_ad_client = “pub-0909510381367095″;
    /* 336×280, created 4/13/08 */
    google_ad_slot = “7189509193″;
    google_ad_width = 336;
    google_ad_height = 280;
    //–>

    Hello Derek,

    The Javascript code quoted above is Google Adsense ad code. It was not added by Local Analytics. If you have any plugin related with Google Adsense, remove it and check your page source again. If that doesn’t help, feel free to contact me again :)

    Joyce

Comment pages
1 2 3 62
  1. April 13th, 2008 at 19:34 | #1
  2. April 14th, 2008 at 07:08 | #2
  3. April 14th, 2008 at 07:09 | #3
  4. July 16th, 2008 at 12:44 | #4
  5. December 3rd, 2008 at 07:41 | #5
  6. February 25th, 2009 at 06:31 | #6
  7. May 17th, 2009 at 06:14 | #7