diff --git a/sites/all/modules/google_analytics/LICENSE.txt b/sites/all/modules/google_analytics/LICENSE.txt
new file mode 100644
index 0000000000000000000000000000000000000000..2c095c8d3f42488e8168f9710a4ffbfc4125a159
--- /dev/null
+++ b/sites/all/modules/google_analytics/LICENSE.txt
@@ -0,0 +1,274 @@
+GNU GENERAL PUBLIC LICENSE
+
+              Version 2, June 1991
+
+Copyright (C) 1989, 1991 Free Software Foundation, Inc. 675 Mass Ave,
+Cambridge, MA 02139, USA. Everyone is permitted to copy and distribute
+verbatim copies of this license document, but changing it is not allowed.
+
+                  Preamble
+
+The licenses for most software are designed to take away your freedom to
+share and change it. By contrast, the GNU General Public License is
+intended to guarantee your freedom to share and change free software--to
+make sure the software is free for all its users. This General Public License
+applies to most of the Free Software Foundation's software and to any other
+program whose authors commit to using it. (Some other Free Software
+Foundation software is covered by the GNU Library General Public License
+instead.) You can apply it to your programs, too.
+
+When we speak of free software, we are referring to freedom, not price. Our
+General Public Licenses are designed to make sure that you have the
+freedom to distribute copies of free software (and charge for this service if
+you wish), that you receive source code or can get it if you want it, that you
+can change the software or use pieces of it in new free programs; and that
+you know you can do these things.
+
+To protect your rights, we need to make restrictions that forbid anyone to
+deny you these rights or to ask you to surrender the rights. These restrictions
+translate to certain responsibilities for you if you distribute copies of the
+software, or if you modify it.
+
+For example, if you distribute copies of such a program, whether gratis or for
+a fee, you must give the recipients all the rights that you have. You must make
+sure that they, too, receive or can get the source code. And you must show
+them these terms so they know their rights.
+
+We protect your rights with two steps: (1) copyright the software, and (2)
+offer you this license which gives you legal permission to copy, distribute
+and/or modify the software.
+
+Also, for each author's protection and ours, we want to make certain that
+everyone understands that there is no warranty for this free software. If the
+software is modified by someone else and passed on, we want its recipients
+to know that what they have is not the original, so that any problems
+introduced by others will not reflect on the original authors' reputations.
+
+Finally, any free program is threatened constantly by software patents. We
+wish to avoid the danger that redistributors of a free program will individually
+obtain patent licenses, in effect making the program proprietary. To prevent
+this, we have made it clear that any patent must be licensed for everyone's
+free use or not licensed at all.
+
+The precise terms and conditions for copying, distribution and modification
+follow.
+
+           GNU GENERAL PUBLIC LICENSE
+ TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND
+               MODIFICATION
+
+0. This License applies to any program or other work which contains a notice
+placed by the copyright holder saying it may be distributed under the terms
+of this General Public License. The "Program", below, refers to any such
+program or work, and a "work based on the Program" means either the
+Program or any derivative work under copyright law: that is to say, a work
+containing the Program or a portion of it, either verbatim or with
+modifications and/or translated into another language. (Hereinafter, translation
+is included without limitation in the term "modification".) Each licensee is
+addressed as "you".
+
+Activities other than copying, distribution and modification are not covered
+by this License; they are outside its scope. The act of running the Program is
+not restricted, and the output from the Program is covered only if its contents
+constitute a work based on the Program (independent of having been made
+by running the Program). Whether that is true depends on what the Program
+does.
+
+1. You may copy and distribute verbatim copies of the Program's source
+code as you receive it, in any medium, provided that you conspicuously and
+appropriately publish on each copy an appropriate copyright notice and
+disclaimer of warranty; keep intact all the notices that refer to this License
+and to the absence of any warranty; and give any other recipients of the
+Program a copy of this License along with the Program.
+
+You may charge a fee for the physical act of transferring a copy, and you
+may at your option offer warranty protection in exchange for a fee.
+
+2. You may modify your copy or copies of the Program or any portion of it,
+thus forming a work based on the Program, and copy and distribute such
+modifications or work under the terms of Section 1 above, provided that you
+also meet all of these conditions:
+
+a) You must cause the modified files to carry prominent notices stating that
+you changed the files and the date of any change.
+
+b) You must cause any work that you distribute or publish, that in whole or in
+part contains or is derived from the Program or any part thereof, to be
+licensed as a whole at no charge to all third parties under the terms of this
+License.
+
+c) If the modified program normally reads commands interactively when run,
+you must cause it, when started running for such interactive use in the most
+ordinary way, to print or display an announcement including an appropriate
+copyright notice and a notice that there is no warranty (or else, saying that
+you provide a warranty) and that users may redistribute the program under
+these conditions, and telling the user how to view a copy of this License.
+(Exception: if the Program itself is interactive but does not normally print such
+an announcement, your work based on the Program is not required to print
+an announcement.)
+
+These requirements apply to the modified work as a whole. If identifiable
+sections of that work are not derived from the Program, and can be
+reasonably considered independent and separate works in themselves, then
+this License, and its terms, do not apply to those sections when you distribute
+them as separate works. But when you distribute the same sections as part
+of a whole which is a work based on the Program, the distribution of the
+whole must be on the terms of this License, whose permissions for other
+licensees extend to the entire whole, and thus to each and every part
+regardless of who wrote it.
+
+Thus, it is not the intent of this section to claim rights or contest your rights to
+work written entirely by you; rather, the intent is to exercise the right to
+control the distribution of derivative or collective works based on the
+Program.
+
+In addition, mere aggregation of another work not based on the Program
+with the Program (or with a work based on the Program) on a volume of a
+storage or distribution medium does not bring the other work under the scope
+of this License.
+
+3. You may copy and distribute the Program (or a work based on it, under
+Section 2) in object code or executable form under the terms of Sections 1
+and 2 above provided that you also do one of the following:
+
+a) Accompany it with the complete corresponding machine-readable source
+code, which must be distributed under the terms of Sections 1 and 2 above
+on a medium customarily used for software interchange; or,
+
+b) Accompany it with a written offer, valid for at least three years, to give
+any third party, for a charge no more than your cost of physically performing
+source distribution, a complete machine-readable copy of the corresponding
+source code, to be distributed under the terms of Sections 1 and 2 above on
+a medium customarily used for software interchange; or,
+
+c) Accompany it with the information you received as to the offer to distribute
+corresponding source code. (This alternative is allowed only for
+noncommercial distribution and only if you received the program in object
+code or executable form with such an offer, in accord with Subsection b
+above.)
+
+The source code for a work means the preferred form of the work for
+making modifications to it. For an executable work, complete source code
+means all the source code for all modules it contains, plus any associated
+interface definition files, plus the scripts used to control compilation and
+installation of the executable. However, as a special exception, the source
+code distributed need not include anything that is normally distributed (in
+either source or binary form) with the major components (compiler, kernel,
+and so on) of the operating system on which the executable runs, unless that
+component itself accompanies the executable.
+
+If distribution of executable or object code is made by offering access to
+copy from a designated place, then offering equivalent access to copy the
+source code from the same place counts as distribution of the source code,
+even though third parties are not compelled to copy the source along with the
+object code.
+
+4. You may not copy, modify, sublicense, or distribute the Program except as
+expressly provided under this License. Any attempt otherwise to copy,
+modify, sublicense or distribute the Program is void, and will automatically
+terminate your rights under this License. However, parties who have received
+copies, or rights, from you under this License will not have their licenses
+terminated so long as such parties remain in full compliance.
+
+5. You are not required to accept this License, since you have not signed it.
+However, nothing else grants you permission to modify or distribute the
+Program or its derivative works. These actions are prohibited by law if you
+do not accept this License. Therefore, by modifying or distributing the
+Program (or any work based on the Program), you indicate your acceptance
+of this License to do so, and all its terms and conditions for copying,
+distributing or modifying the Program or works based on it.
+
+6. Each time you redistribute the Program (or any work based on the
+Program), the recipient automatically receives a license from the original
+licensor to copy, distribute or modify the Program subject to these terms and
+conditions. You may not impose any further restrictions on the recipients'
+exercise of the rights granted herein. You are not responsible for enforcing
+compliance by third parties to this License.
+
+7. If, as a consequence of a court judgment or allegation of patent
+infringement or for any other reason (not limited to patent issues), conditions
+are imposed on you (whether by court order, agreement or otherwise) that
+contradict the conditions of this License, they do not excuse you from the
+conditions of this License. If you cannot distribute so as to satisfy
+simultaneously your obligations under this License and any other pertinent
+obligations, then as a consequence you may not distribute the Program at all.
+For example, if a patent license would not permit royalty-free redistribution
+of the Program by all those who receive copies directly or indirectly through
+you, then the only way you could satisfy both it and this License would be to
+refrain entirely from distribution of the Program.
+
+If any portion of this section is held invalid or unenforceable under any
+particular circumstance, the balance of the section is intended to apply and
+the section as a whole is intended to apply in other circumstances.
+
+It is not the purpose of this section to induce you to infringe any patents or
+other property right claims or to contest validity of any such claims; this
+section has the sole purpose of protecting the integrity of the free software
+distribution system, which is implemented by public license practices. Many
+people have made generous contributions to the wide range of software
+distributed through that system in reliance on consistent application of that
+system; it is up to the author/donor to decide if he or she is willing to
+distribute software through any other system and a licensee cannot impose
+that choice.
+
+This section is intended to make thoroughly clear what is believed to be a
+consequence of the rest of this License.
+
+8. If the distribution and/or use of the Program is restricted in certain
+countries either by patents or by copyrighted interfaces, the original copyright
+holder who places the Program under this License may add an explicit
+geographical distribution limitation excluding those countries, so that
+distribution is permitted only in or among countries not thus excluded. In such
+case, this License incorporates the limitation as if written in the body of this
+License.
+
+9. The Free Software Foundation may publish revised and/or new versions
+of the General Public License from time to time. Such new versions will be
+similar in spirit to the present version, but may differ in detail to address new
+problems or concerns.
+
+Each version is given a distinguishing version number. If the Program specifies
+a version number of this License which applies to it and "any later version",
+you have the option of following the terms and conditions either of that
+version or of any later version published by the Free Software Foundation. If
+the Program does not specify a version number of this License, you may
+choose any version ever published by the Free Software Foundation.
+
+10. If you wish to incorporate parts of the Program into other free programs
+whose distribution conditions are different, write to the author to ask for
+permission. For software which is copyrighted by the Free Software
+Foundation, write to the Free Software Foundation; we sometimes make
+exceptions for this. Our decision will be guided by the two goals of
+preserving the free status of all derivatives of our free software and of
+promoting the sharing and reuse of software generally.
+
+               NO WARRANTY
+
+11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE,
+THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT
+PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE
+STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR
+OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT
+WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED,
+INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND
+PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE
+PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL
+NECESSARY SERVICING, REPAIR OR CORRECTION.
+
+12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR
+AGREED TO IN WRITING WILL ANY COPYRIGHT HOLDER, OR
+ANY OTHER PARTY WHO MAY MODIFY AND/OR
+REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE
+LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL,
+SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES
+ARISING OUT OF THE USE OR INABILITY TO USE THE
+PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF DATA
+OR DATA BEING RENDERED INACCURATE OR LOSSES
+SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF THE
+PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), EVEN
+IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF
+THE POSSIBILITY OF SUCH DAMAGES.
+
+          END OF TERMS AND CONDITIONS
diff --git a/sites/all/modules/google_analytics/README.txt b/sites/all/modules/google_analytics/README.txt
new file mode 100644
index 0000000000000000000000000000000000000000..a17a80eb262f1514c8d4b004844f20f6a0a3b6a2
--- /dev/null
+++ b/sites/all/modules/google_analytics/README.txt
@@ -0,0 +1,76 @@
+// $Id: README.txt,v 1.10.2.4 2011/02/07 16:56:27 hass Exp $
+
+Module: Google Analytics
+Author: Alexander Hass <http://drupal.org/user/85918>
+
+
+Description
+===========
+Adds the Google Analytics tracking system to your website.
+
+Requirements
+============
+
+* Google Analytics user account
+
+
+Installation
+============
+* Copy the 'googleanalytics' module directory in to your Drupal
+sites/all/modules directory as usual.
+
+
+Usage
+=====
+In the settings page enter your Google Analytics account number.
+
+All pages will now have the required JavaScript added to the
+HTML footer can confirm this by viewing the page source from
+your browser.
+
+New approach to page tracking in 5.x-1.5 and 6.x-1.1
+====================================================
+With 5.x-1.5 and 6.x-1.1 there are new settings on the settings page at
+admin/config/system/googleanalytics. The "Page specific tracking" area now
+comes with an interface that copies Drupal's block visibility settings.
+
+The default is set to "Add to every page except the listed pages". By
+default the following pages are listed for exclusion:
+
+admin
+admin/*
+user/*/*
+node/add*
+node/*/*
+
+These defaults are changeable by the website administrator or any other
+user with 'administer google analytics' permission.
+
+Like the blocks visibility settings in Drupal core, there is now a
+choice for "Add if the following PHP code returns TRUE." Sample PHP snippets
+that can be used in this textarea can be found on the handbook page
+"Overview-approach to block visibility" at http://drupal.org/node/64135.
+
+Custom variables
+=================
+One example for custom variables tracking is the "User roles" tracking. Enter
+the below configuration data into the custom variables settings form under
+admin/config/system/googleanalytics.
+
+Slot: 1
+Name: User roles
+Value: [current-user:role-names]
+Scope: Visitor
+
+More details about Custom variables can be found in the Google API documentation at
+http://code.google.com/intl/en/apis/analytics/docs/tracking/gaTrackingCustomVariables.html
+
+Advanced Settings
+=================
+You can include additional JavaScript snippets in the custom javascript
+code textarea. These can be found on the official Google Analytics pages
+and a few examples at http://drupal.org/node/248699. Support is not
+provided for any customisations you include.
+
+To speed up page loading you may also cache the Analytics ga.js
+file locally.
diff --git a/sites/all/modules/google_analytics/googleanalytics.admin.inc b/sites/all/modules/google_analytics/googleanalytics.admin.inc
new file mode 100644
index 0000000000000000000000000000000000000000..4102eec83966f6a118a256f755f6e2b0ca6bd4e3
--- /dev/null
+++ b/sites/all/modules/google_analytics/googleanalytics.admin.inc
@@ -0,0 +1,579 @@
+<?php
+// $Id: googleanalytics.admin.inc,v 1.24.2.28 2011/02/07 14:41:11 hass Exp $
+
+/**
+ * @file
+ * Administrative page callbacks for the googleanalytics module.
+ */
+
+/**
+ * Implements hook_admin_settings() for module settings configuration.
+ */
+function googleanalytics_admin_settings_form($form_state) {
+  $form['account'] = array(
+    '#type' => 'fieldset',
+    '#title' => t('General settings'),
+  );
+
+  $form['account']['googleanalytics_account'] = array(
+    '#title' => t('Web Property ID'),
+    '#type' => 'textfield',
+    '#default_value' => variable_get('googleanalytics_account', 'UA-'),
+    '#size' => 15,
+    '#maxlength' => 20,
+    '#required' => TRUE,
+    '#description' => t('This ID is unique to each site you want to track separately, and is in the form of UA-xxxxxxx-yy. To get a Web Property ID, <a href="@analytics">register your site with Google Analytics</a>, or if you already have registered your site, go to your Google Analytics Settings page to see the ID next to every site profile. <a href="@webpropertyid">Find more information in the documentation</a>.', array('@analytics' => 'http://www.google.com/analytics/', '@webpropertyid' => 'http://code.google.com/apis/analytics/docs/concepts/gaConceptsAccounts.html#webProperty')),
+  );
+
+  // Visibility settings.
+  $form['tracking_title'] = array(
+    '#type' => 'item',
+    '#title' => t('Tracking scope'),
+  );
+  $form['tracking'] = array(
+    '#type' => 'vertical_tabs',
+    '#attached' => array(
+      'js' => array(drupal_get_path('module', 'googleanalytics') . '/googleanalytics.admin.js'),
+    ),
+  );
+
+  $form['tracking']['domain_tracking'] = array(
+    '#type' => 'fieldset',
+    '#title' => t('Domains'),
+  );
+
+  global $cookie_domain;
+  $multiple_sub_domains = array();
+  foreach (array('www', 'app', 'shop') as $subdomain) {
+    if (count(explode('.', $cookie_domain)) > 2 && !is_numeric(str_replace('.', '', $cookie_domain))) {
+      $multiple_sub_domains[] = $subdomain . $cookie_domain;
+    }
+    // IP addresses or localhost.
+    else {
+      $multiple_sub_domains[] = $subdomain . '.example.com';
+    }
+  }
+
+  $multiple_toplevel_domains = array();
+  foreach (array('.com', '.net', '.org') as $tldomain) {
+    $host = $_SERVER['HTTP_HOST'];
+    $domain = substr($host, 0, strrpos($host, '.'));
+    if (count(explode('.', $host)) > 2 && !is_numeric(str_replace('.', '', $host))) {
+      $multiple_toplevel_domains[] = $domain . $tldomain;
+    }
+    // IP addresses or localhost
+    else {
+      $multiple_toplevel_domains[] = 'www.example' . $tldomain;
+    }
+  }
+
+  $form['tracking']['domain_tracking']['googleanalytics_domain_mode'] = array(
+    '#type' => 'radios',
+    '#title' => t('What are you tracking?'),
+    '#options' => array(
+      0 => t('A single domain (default)') . '<div class="description">' . t('Domain: @domain', array('@domain' => $_SERVER['HTTP_HOST'])) . '</div>',
+      1 => t('One domain with multiple subdomains') . '<div class="description">' . t('Examples: @domains', array('@domains' => implode(', ', $multiple_sub_domains))) . '</div>',
+      2 => t('Multiple top-level domains') . '<div class="description">' . t('Examples: @domains', array('@domains' => implode(', ', $multiple_toplevel_domains))) . '</div>',
+    ),
+    '#default_value' => variable_get('googleanalytics_domain_mode', 0),
+  );
+  $form['tracking']['domain_tracking']['googleanalytics_cross_domains'] = array(
+    '#title' => t('List of top-level domains'),
+    '#type' => 'textarea',
+    '#default_value' => variable_get('googleanalytics_cross_domains', ''),
+    '#description' => t('If you selected "Multiple top-level domains" above, enter all related top-level domains. Add one domain per line. By default, the data in your reports only includes the path and name of the page, and not the domain name. For more information see section <em>Show separate domain names</em> in <a href="http://www.google.com/support/analytics/bin/answer.py?answer=175538">Tracking multiple domains</a>.'),
+  );
+
+  // Page specific visibility configurations.
+  $php_access = user_access('use PHP for tracking visibility');
+  $visibility = variable_get('googleanalytics_visibility_pages', 0);
+  $pages = variable_get('googleanalytics_pages', '');
+
+  $form['tracking']['page_vis_settings'] = array(
+    '#type' => 'fieldset',
+    '#title' => t('Pages'),
+    '#collapsible' => TRUE,
+    '#collapsed' => TRUE,
+  );
+
+  if ($visibility == 2 && !$php_access) {
+    $form['tracking']['page_vis_settings'] = array();
+    $form['tracking']['page_vis_settings']['visibility'] = array('#type' => 'value', '#value' => 2);
+    $form['tracking']['page_vis_settings']['pages'] = array('#type' => 'value', '#value' => $pages);
+  }
+  else {
+    $options = array(
+      t('Every page except the listed pages'),
+      t('The listed pages only'),
+    );
+    $description = t("Specify pages by using their paths. Enter one path per line. The '*' character is a wildcard. Example paths are %blog for the blog page and %blog-wildcard for every personal blog. %front is the front page.", array('%blog' => 'blog', '%blog-wildcard' => 'blog/*', '%front' => '<front>'));
+
+    if (module_exists('php') && $php_access) {
+      $options[] = t('Pages on which this PHP code returns <code>TRUE</code> (experts only)');
+      $title = t('Pages or PHP code');
+      $description .= ' ' . t('If the PHP option is chosen, enter PHP code between %php. Note that executing incorrect PHP code can break your Drupal site.', array('%php' => '<?php ?>'));
+    }
+    else {
+      $title = t('Pages');
+    }
+    $form['tracking']['page_vis_settings']['googleanalytics_visibility_pages'] = array(
+      '#type' => 'radios',
+      '#title' => t('Add tracking to specific pages'),
+      '#options' => $options,
+      '#default_value' => $visibility,
+    );
+    $form['tracking']['page_vis_settings']['googleanalytics_pages'] = array(
+      '#type' => 'textarea',
+      '#title' => $title,
+      '#title_display' => 'invisible',
+      '#default_value' => $pages,
+      '#description' => $description,
+      '#rows' => 10,
+    );
+  }
+
+  // Render the role overview.
+  $form['tracking']['role_vis_settings'] = array(
+    '#type' => 'fieldset',
+    '#title' => t('Roles'),
+  );
+
+  $form['tracking']['role_vis_settings']['googleanalytics_visibility_roles'] = array(
+    '#type' => 'radios',
+    '#title' => t('Add tracking for specific roles'),
+    '#options' => array(
+      t('Add to the selected roles only'),
+      t('Add to every role except the selected ones'),
+    ),
+    '#default_value' => variable_get('googleanalytics_visibility_roles', 0),
+  );
+
+  $role_options = array_map('check_plain', user_roles());
+  $form['tracking']['role_vis_settings']['googleanalytics_roles'] = array(
+    '#type' => 'checkboxes',
+    '#title' => t('Roles'),
+    '#default_value' => variable_get('googleanalytics_roles', array()),
+    '#options' => $role_options,
+    '#description' => t('If none of the roles are selected, all users will be tracked. If a user has any of the roles checked, that user will be tracked (or excluded, depending on the setting above).'),
+  );
+
+  // Standard tracking configurations.
+  $form['tracking']['user_vis_settings'] = array(
+    '#type' => 'fieldset',
+    '#title' => t('Users'),
+  );
+  $t_permission = array('%permission' => t('opt-in or out of tracking'));
+  $form['tracking']['user_vis_settings']['googleanalytics_custom'] = array(
+    '#type' => 'radios',
+    '#title' => t('Allow users to customize tracking on their account page'),
+    '#options' => array(
+      t('No customization allowed'),
+      t('Tracking on by default, users with %permission permission can opt out', $t_permission),
+      t('Tracking off by default, users with %permission permission can opt in', $t_permission),
+    ),
+    '#default_value' => variable_get('googleanalytics_custom', 0),
+  );
+
+  // Link specific configurations.
+  $form['tracking']['linktracking'] = array(
+    '#type' => 'fieldset',
+    '#title' => t('Links and downloads'),
+  );
+  $form['tracking']['linktracking']['googleanalytics_trackoutbound'] = array(
+    '#type' => 'checkbox',
+    '#title' => t('Track clicks on outbound links'),
+    '#default_value' => variable_get('googleanalytics_trackoutbound', 1),
+  );
+  $form['tracking']['linktracking']['googleanalytics_trackmailto'] = array(
+    '#type' => 'checkbox',
+    '#title' => t('Track clicks on mailto links'),
+    '#default_value' => variable_get('googleanalytics_trackmailto', 1),
+  );
+  $form['tracking']['linktracking']['googleanalytics_trackfiles'] = array(
+    '#type' => 'checkbox',
+    '#title' => t('Track downloads (clicks on file links) for the following extensions'),
+    '#default_value' => variable_get('googleanalytics_trackfiles', 1),
+  );
+  $form['tracking']['linktracking']['googleanalytics_trackfiles_extensions'] = array(
+    '#title' => t('List of download file extensions'),
+    '#title_display' => 'invisible',
+    '#type' => 'textfield',
+    '#default_value' => variable_get('googleanalytics_trackfiles_extensions', GA_TRACKFILES_EXTENSIONS),
+    '#description' => t('A file extension list separated by the | character that will be tracked as download when clicked. Regular expressions are supported. For example: !extensions', array('!extensions' => GA_TRACKFILES_EXTENSIONS)),
+    '#maxlength' => 255,
+  );
+  $form['tracking']['linktracking']['googleanalytics_trackoutboundaspageview'] = array(
+    '#type' => 'checkbox',
+    '#title' => t('Track clicks on outbound links as page views'),
+    '#default_value' => variable_get('googleanalytics_trackoutboundaspageview', 0),
+    '#description' => t('By default outbound links are tracked as <em>Events</em>. In rare situations like tracking of <em>Goals</em> it may be required to track outbound clicks as page views.'),
+  );
+
+  // Google already have many translations, if not - they display a note to change the language.
+  global $language;
+  $form['tracking']['search_and_adsense'] = array(
+    '#type' => 'fieldset',
+    '#title' => t('Search and AdSense'),
+  );
+
+  $site_search_dependencies = '<div class="admin-dependencies">';
+  $site_search_dependencies .= t('Depends on: !dependencies', array('!dependencies' => (module_exists('search') ? t('@module (<span class="admin-enabled">enabled</span>)', array('@module' => 'Search')) : t('@module (<span class="admin-disabled">disabled</span>)', array('@module' => 'Search')))));
+  $site_search_dependencies .= '</div>';
+
+  $form['tracking']['search_and_adsense']['googleanalytics_site_search'] = array(
+    '#type' => 'checkbox',
+    '#title' => t('Track internal search'),
+    '#description' => t('If checked, internal search keywords are tracked. You must configure your Google account to use the internal query parameter <strong>search</strong>. For more information see <a href="@url">How do I set up Site Search for my profile</a>.', array('@url' => 'http://www.google.com/support/analytics/bin/answer.py?hl=' . $language->language . '&answer=75817')) . $site_search_dependencies,
+    '#default_value' => variable_get('googleanalytics_site_search', FALSE),
+    '#disabled' => (module_exists('search') ? FALSE : TRUE),
+  );
+
+  $form['tracking']['search_and_adsense']['googleanalytics_trackadsense'] = array(
+    '#type' => 'checkbox',
+    '#title' => t('Track AdSense ads'),
+    '#description' => t('If checked, your AdSense ads will be tracked in your Google Analytics account.'),
+    '#default_value' => variable_get('googleanalytics_trackadsense', FALSE),
+  );
+
+  // Backward compatibility only.
+  // TODO: If currently not in use, hide the UI and later remove the code.
+  $segmentation = variable_get('googleanalytics_segmentation', array());
+
+  if (!empty($segmentation) || variable_get('googleanalytics_segmentation_DEPRECATED', FALSE)) {
+    $profile_enabled = module_exists('profile');
+    $form['segmentation'] = array(
+      '#type' => 'fieldset',
+      '#title' => t('Additional user information'),
+      '#collapsible' => TRUE,
+    );
+
+    // Compile a list of fields to show.
+    $fields = variable_get('googleanalytics_segmentation_default_fields', array('roles' => t('User roles')));
+    if ($profile_enabled) {
+      $result = db_query('SELECT name, title FROM {profile_field} ORDER BY weight');
+      foreach ($result as $record) {
+        $fields[$record->name] = $record->title;
+      }
+    }
+
+    $form['segmentation']['googleanalytics_segmentation'] = array(
+      '#type' => 'select',
+      '#title' => t('Segment users based on these selected properties') . ' <span class="admin-disabled">***DEPRECATED***</span>',
+      '#description' => t("You can supplement Google Analytics' basic IP address tracking of visitors by segmenting users based on these selected properties.") . ' <span class="admin-disabled">' . t('For most situations, Google recommend that you use Custom Variables to segment your visitors.') . '</span>' . (!$profile_enabled ? ' ' . t('<a href="@module_list">Enable the profile module</a> to be able to use profile fields for more granular tracking.', array('@module_list' => url('admin/build/modules'))) : '') . ' ' . t('Section 8.1 of the <a href="@ga_tos">Google Analytics terms of use</a> requires you to make sure you will not associate (or permit any third party to associate) any data gathered from your websites (or such third parties\' websites) with any personally identifying information from any source as part of your use (or such third parties\' use) of the Google Analytics\' service.', array('@ga_tos' => 'http://www.google.com/analytics/en-GB/tos.html')) . ' ' . t('You can select multiple values.'),
+      '#default_value' => $segmentation,
+      '#options' => $fields,
+      '#size' => count($fields)>3 ? 10 : 3,
+      '#multiple' => TRUE,
+    );
+  }
+
+  $form['googleanalytics_custom_var'] = array(
+    '#collapsible' => TRUE,
+    '#description' => t('You can add Google Analytics <a href="!custom_var_documentation">Custom Variables</a> here. These will be added to every page that Google Analytics tracking code appears on. Google Analytics will only accept custom variables if the <em>name</em> and <em>value</em> combined are less than 64 bytes after URL encoding. Keep the names as short as possible and expect long values to get trimmed. You may use tokens in custom variable values. Global and user tokens are always available; on node pages, node tokens are also available.', array('!custom_var_documentation' => 'http://code.google.com/intl/en/apis/analytics/docs/tracking/gaTrackingCustomVariables.html')),
+    '#theme' => 'googleanalytics_admin_custom_var_table',
+    '#title' => t('Custom variables'),
+    '#tree' => TRUE,
+    '#type' => 'fieldset',
+  );
+
+  $googleanalytics_custom_vars = variable_get('googleanalytics_custom_var', array());
+
+  // Google Analytics supports up to 5 custom variables.
+  for ($i = 1; $i < 6; $i++) {
+    $form['googleanalytics_custom_var']['slots'][$i]['slot'] = array(
+      '#default_value' => $i,
+      '#description' => t('Slot number'),
+      '#disabled' => TRUE,
+      '#size' => 1,
+      '#title' => t('Custom variable slot #@slot', array('@slot' => $i)),
+      '#title_display' => 'invisible',
+      '#type' => 'textfield',
+    );
+    $form['googleanalytics_custom_var']['slots'][$i]['name'] = array(
+      '#default_value' => !empty($googleanalytics_custom_vars['slots'][$i]['name']) ? $googleanalytics_custom_vars['slots'][$i]['name'] : '',
+      '#description' => t('The custom variable name.'),
+      '#size' => 20,
+      '#title' => t('Custom variable name #@slot', array('@slot' => $i)),
+      '#title_display' => 'invisible',
+      '#type' => 'textfield',
+    );
+    $form['googleanalytics_custom_var']['slots'][$i]['value'] = array(
+      '#default_value' => !empty($googleanalytics_custom_vars['slots'][$i]['value']) ? $googleanalytics_custom_vars['slots'][$i]['value'] : '',
+      '#description' => t('The custom variable value. You may use tokens in this field.'),
+      '#title' => t('Custom variable value #@slot', array('@slot' => $i)),
+      '#title_display' => 'invisible',
+      '#type' => 'textfield',
+      '#element_validate' => array('googleanalytics_token_element_validate'),
+      '#token_types' => array('node'),
+    );
+    if (module_exists('token')) {
+      $form['googleanalytics_custom_var']['slots'][$i]['value']['#element_validate'][] = 'token_element_validate';
+    }
+    $form['googleanalytics_custom_var']['slots'][$i]['scope'] = array(
+      '#default_value' => !empty($googleanalytics_custom_vars['slots'][$i]['scope']) ? $googleanalytics_custom_vars['slots'][$i]['scope'] : 3,
+      '#description' => t('The scope for the custom variable.'),
+      '#title' => t('Custom variable slot #@slot', array('@slot' => $i)),
+      '#title_display' => 'invisible',
+      '#type' => 'select',
+      '#options' => array(
+        1 => t('Visitor'),
+        2 => t('Session'),
+        3 => t('Page'),
+      ),
+    );
+  }
+
+  $form['googleanalytics_custom_var']['googleanalytics_custom_var_description'] = array(
+    '#type' => 'item',
+    '#description' => t('You can supplement Google Analytics\' basic IP address tracking of visitors by segmenting users based on custom variables. Section 8.1 of the <a href="@ga_tos">Google Analytics terms of use</a> requires you to make sure you will not associate (or permit any third party to associate) any data gathered from your websites (or such third parties\' websites) with any personally identifying information from any source as part of your use (or such third parties\' use) of the Google Analytics\' service.', array('@ga_tos' => 'http://www.google.com/analytics/en-GB/tos.html')),
+  );
+  $form['googleanalytics_custom_var']['googleanalytics_custom_var_token_tree'] = array(
+    '#theme' => 'token_tree',
+    '#token_types' => array('node'),
+  );
+
+
+  // Advanced feature configurations.
+  $form['advanced'] = array(
+    '#type' => 'fieldset',
+    '#title' => t('Advanced settings'),
+    '#collapsible' => TRUE,
+    '#collapsed' => TRUE,
+  );
+
+  $form['advanced']['googleanalytics_tracker_anonymizeip'] = array(
+    '#type' => 'checkbox',
+    '#title' => t('Anonymize visitors IP address'),
+    '#description' => t('Tell Google Analytics to anonymize the information sent by the tracker objects by removing the last octet of the IP address prior to its storage. Note that this will slightly reduce the accuracy of geographic reporting. In some countries it is not allowed to collect personally identifying information for privacy reasons and this setting may help you to comply with the local laws.'),
+    '#default_value' => variable_get('googleanalytics_tracker_anonymizeip', 0),
+  );
+
+  $form['advanced']['googleanalytics_cache'] = array(
+    '#type' => 'checkbox',
+    '#title' => t('Locally cache tracking code file'),
+    '#description' => t("If checked, the tracking code file is retrieved from Google Analytics and cached locally. It is updated daily from Google's servers to ensure updates to tracking code are reflected in the local copy. Do not activate this until after Google Analytics has confirmed that site tracking is working!"),
+    '#default_value' => variable_get('googleanalytics_cache', 0),
+  );
+
+  // Allow for tracking of the originating node when viewing translation sets.
+  if (module_exists('translation')) {
+    $form['advanced']['googleanalytics_translation_set'] = array(
+      '#type' => 'checkbox',
+      '#title' => t('Track translation sets as one unit'),
+      '#description' => t('When a node is part of a translation set, record statistics for the originating node instead. This allows for a translation set to be treated as a single unit.'),
+      '#default_value' => variable_get('googleanalytics_translation_set', 0),
+    );
+  }
+
+  $form['advanced']['codesnippet'] = array(
+    '#type' => 'fieldset',
+    '#title' => t('Custom JavaScript code'),
+    '#collapsible' => TRUE,
+    '#collapsed' => TRUE,
+    '#description' => t('You can add custom Google Analytics <a href="@snippets">code snippets</a> here. These will be added every time tracking is in effect. Before you add your custom code, you should read the <a href="@ga_concepts_overview">Google Analytics Tracking Code - Functional Overview</a> and the <a href="@ga_js_api">Google Analytics Tracking API</a> documentation. <strong>Do not include the &lt;script&gt; tags</strong>, and always end your code with a semicolon (;).', array('@snippets' => 'http://drupal.org/node/248699', '@ga_concepts_overview' => 'http://code.google.com/apis/analytics/docs/gaConceptsOverview.html', '@ga_js_api' => 'http://code.google.com/apis/analytics/docs/gaJSApi.html')),
+  );
+  $form['advanced']['codesnippet']['googleanalytics_codesnippet_before'] = array(
+    '#type' => 'textarea',
+    '#title' => t('Code snippet (before)'),
+    '#default_value' => variable_get('googleanalytics_codesnippet_before', ''),
+    '#rows' => 5,
+    '#description' => t("Code in this textarea will be added <strong>before</strong> _gaq.push(['_trackPageview'])."),
+  );
+  $form['advanced']['codesnippet']['googleanalytics_codesnippet_after'] = array(
+    '#type' => 'textarea',
+    '#title' => t('Code snippet (after)'),
+    '#default_value' => variable_get('googleanalytics_codesnippet_after', ''),
+    '#rows' => 5,
+    '#description' => t("Code in this textarea will be added <strong>after</strong> _gaq.push(['_trackPageview']). This is useful if you'd like to track a site in two accounts."),
+  );
+
+  $form['advanced']['googleanalytics_js_scope'] = array(
+    '#type' => 'select',
+    '#title' => t('JavaScript scope'),
+    '#description' => t('Google recommends adding the external JavaScript files to the header for performance reasons. If <em>Multiple top-level domains</em> has been selected, this setting will be forced to header.'),
+    '#options' => array(
+      'footer' => t('Footer'),
+      'header' => t('Header'),
+    ),
+    '#default_value' => variable_get('googleanalytics_js_scope', 'header'),
+    '#disabled' => (variable_get('googleanalytics_domain_mode', 0) == 2) ? TRUE : FALSE,
+  );
+
+  return system_settings_form($form);
+}
+
+/**
+ * Implements _form_validate().
+ */
+function googleanalytics_admin_settings_form_validate($form, &$form_state) {
+  // Custom variables validation.
+  foreach ($form_state['values']['googleanalytics_custom_var']['slots'] as $custom_var) {
+    // Validate empty names/values.
+    if (empty($custom_var['name']) && !empty($custom_var['value'])) {
+      form_set_error("googleanalytics_custom_var][slots][" . $custom_var['slot'] . "][name", t('The custom variable @slot-number requires a <em>Value</em> if a <em>Name</em> has been provided.', array('@slot-number' =>  $custom_var['slot'])));
+    }
+    elseif (!empty($custom_var['name']) && empty($custom_var['value'])) {
+      form_set_error("googleanalytics_custom_var][slots][" . $custom_var['slot'] . "][value", t('The custom variable @slot-number requires a <em>Name</em> if a <em>Value</em> has been provided.', array('@slot-number' =>  $custom_var['slot'])));
+    }
+  }
+
+  // Trim some text values.
+  $form_state['values']['googleanalytics_account'] = trim($form_state['values']['googleanalytics_account']);
+  $form_state['values']['googleanalytics_pages'] = trim($form_state['values']['googleanalytics_pages']);
+  $form_state['values']['googleanalytics_cross_domains'] = trim($form_state['values']['googleanalytics_cross_domains']);
+  $form_state['values']['googleanalytics_codesnippet_before'] = trim($form_state['values']['googleanalytics_codesnippet_before']);
+  $form_state['values']['googleanalytics_codesnippet_after'] = trim($form_state['values']['googleanalytics_codesnippet_after']);
+
+  if (!preg_match('/^UA-\d{4,}-\d+$/', $form_state['values']['googleanalytics_account'])) {
+    form_set_error('googleanalytics_account', t('A valid Google Analytics Web Property ID is case sensitive and formatted like UA-xxxxxxx-yy.'));
+  }
+
+  // If multiple top-level domains has been selected, a domain names list is required.
+  if ($form_state['values']['googleanalytics_domain_mode'] == 2 && empty($form_state['values']['googleanalytics_cross_domains'])) {
+    form_set_error('googleanalytics_cross_domains', t('A list of top-level domains is required if <em>Multiple top-level domains</em> has been selected.'));
+  }
+  // Clear obsolete local cache if cache has been disabled.
+  if (empty($form_state['values']['googleanalytics_cache']) && $form['advanced']['googleanalytics_cache']['#default_value']) {
+    googleanalytics_clear_js_cache();
+  }
+
+  // This is for the Newbie's who cannot read a text area description.
+  if (stristr($form_state['values']['googleanalytics_codesnippet_before'], 'google-analytics.com/ga.js')) {
+    form_set_error('googleanalytics_codesnippet_before', t('Do not add the tracker code provided by Google into the javascript code snippets! This module already builds the tracker code based on your Google Analytics account number and settings.'));
+  }
+  if (stristr($form_state['values']['googleanalytics_codesnippet_after'], 'google-analytics.com/ga.js')) {
+    form_set_error('googleanalytics_codesnippet_after', t('Do not add the tracker code provided by Google into the javascript code snippets! This module already builds the tracker code based on your Google Analytics account number and settings.'));
+  }
+  if (preg_match('/(.*)<\/?script(.*)>(.*)/i', $form_state['values']['googleanalytics_codesnippet_before'])) {
+    form_set_error('googleanalytics_codesnippet_before', t('Do not include the &lt;script&gt; tags in the javascript code snippets.'));
+  }
+  if (preg_match('/(.*)<\/?script(.*)>(.*)/i', $form_state['values']['googleanalytics_codesnippet_after'])) {
+    form_set_error('googleanalytics_codesnippet_after', t('Do not include the &lt;script&gt; tags in the javascript code snippets.'));
+  }
+
+  // Header section must be forced for multiple top-level domains.
+  if ($form_state['values']['googleanalytics_domain_mode'] == 2) {
+    $form_state['values']['googleanalytics_js_scope'] = 'header';
+  }
+}
+
+/**
+ * Layout for the custom variables table in the admin settings form.
+ */
+function theme_googleanalytics_admin_custom_var_table($variables) {
+  $form = $variables['form'];
+
+  $header = array(
+    array('data' => t('Slot')),
+    array('data' => t('Name')),
+    array('data' => t('Value')),
+    array('data' => t('Scope')),
+  );
+
+  $rows = array();
+  foreach (element_children($form['slots']) as $key => $id) {
+    $rows[] = array(
+      'data' => array(
+        drupal_render($form['slots'][$id]['slot']),
+        drupal_render($form['slots'][$id]['name']),
+        drupal_render($form['slots'][$id]['value']),
+        drupal_render($form['slots'][$id]['scope']),
+      ),
+    );
+  }
+
+  $output = theme('table', array('header' => $header, 'rows' => $rows));
+  $output .= drupal_render($form['googleanalytics_custom_var_description']);
+  $output .= drupal_render($form['googleanalytics_custom_var_token_tree']);
+
+  return $output;
+}
+
+/**
+ * Validate a form element that should have tokens in it.
+ *
+ * For example:
+ * @code
+ * $form['my_node_text_element'] = array(
+ *   '#type' => 'textfield',
+ *   '#title' => t('Some text to token-ize that has a node context.'),
+ *   '#default_value' => 'The title of this node is [node:title].',
+ *   '#element_validate' => array('googleanalytics_token_element_validate'),
+ * );
+ * @endcode
+ */
+function googleanalytics_token_element_validate(&$element, &$form_state) {
+  $value = isset($element['#value']) ? $element['#value'] : $element['#default_value'];
+
+  if (!drupal_strlen($value)) {
+    // Empty value needs no further validation since the element should depend
+    // on using the '#required' FAPI property.
+    return $element;
+  }
+
+  $tokens = token_scan($value);
+  $invalid_tokens = _googleanalytics_get_forbidden_tokens($tokens);
+  if ($invalid_tokens) {
+    form_error($element, t('The %element-title is using the following forbidden tokens with personal identifying information: @invalid-tokens.', array('%element-title' => $element['#title'], '@invalid-tokens' => implode(', ', $invalid_tokens))));
+  }
+
+  return $element;
+}
+
+function _googleanalytics_get_forbidden_tokens($value) {
+  $invalid_tokens = array();
+  $value_tokens = is_string($value) ? token_scan($value) : $value;
+
+  foreach ($value_tokens as $type => $tokens) {
+    if (array_filter($tokens, '_googleanalytics_contains_forbidden_token')) {
+      $invalid_tokens = array_merge($invalid_tokens, array_values($tokens));
+    }
+  }
+
+  array_unique($invalid_tokens);
+  return $invalid_tokens;
+}
+
+/**
+ * Validate if a string contains forbidden tokens not allowed by privacy rules.
+ *
+ * @param $token_string
+ *   A string with one or more tokens to be validated.
+ * @return boolean
+ *   TRUE if blacklisted token has been found, otherwise FALSE.
+ */
+function _googleanalytics_contains_forbidden_token($token_string) {
+  // List of strings in tokens with personal identifying information not allowed
+  // for privacy reasons. See section 8.1 of the Google Analytics terms of use
+  // for more detailed information.
+  //
+  // This list can never ever be complete. For this reason it tries to use a
+  // regex and may kill a few other valid tokens, but it's the only way to
+  // protect users as much as possible from admins with illegal ideas.
+  //
+  // User tokens are not prefixed with colon to catch 'current-user' and 'user'.
+  //
+  // TODO: If someone have better ideas, share them, please!
+  $token_blacklist = array(
+    ':author]',
+    ':author:edit-url]',
+    ':author:url]',
+    ':author:path]',
+    ':fid]',
+    ':mail]',
+    ':name]',
+    ':uid]',
+    ':one-time-login-url]',
+    ':owner]',
+    ':owner:cancel-url]',
+    ':owner:edit-url]',
+    ':owner:url]',
+    ':owner:path]',
+    'user:cancel-url]',
+    'user:edit-url]',
+    'user:url]',
+    'user:path]',
+  );
+
+  return preg_match('/' . implode('|', array_map('preg_quote', $token_blacklist)) . '/i', $token_string);
+}
diff --git a/sites/all/modules/google_analytics/googleanalytics.admin.js b/sites/all/modules/google_analytics/googleanalytics.admin.js
new file mode 100644
index 0000000000000000000000000000000000000000..3571c8c9294c71ac92565ad2627d1fefaaeb95ff
--- /dev/null
+++ b/sites/all/modules/google_analytics/googleanalytics.admin.js
@@ -0,0 +1,104 @@
+// $Id: googleanalytics.admin.js,v 1.1.2.7 2011/02/07 15:20:57 hass Exp $
+(function ($) {
+
+/**
+ * Provide the summary information for the tracking settings vertical tabs.
+ */
+Drupal.behaviors.trackingSettingsSummary = {
+  attach: function (context) {
+    // Make sure this behavior is processed only if drupalSetSummary is defined.
+    if (typeof jQuery.fn.drupalSetSummary == 'undefined') {
+      return;
+    }
+
+    $('fieldset#edit-page-vis-settings', context).drupalSetSummary(function (context) {
+      var $radio = $('input[name="googleanalytics_visibility_pages"]:checked', context);
+      if ($radio.val() == 0) {
+        if (!$('textarea[name="googleanalytics_pages"]', context).val()) {
+          return Drupal.t('Not restricted');
+        }
+        else {
+          return Drupal.t('All pages with exceptions');
+        }
+      }
+      else {
+        return Drupal.t('Restricted to certain pages');
+      }
+    });
+
+    $('fieldset#edit-role-vis-settings', context).drupalSetSummary(function (context) {
+      var vals = [];
+      $('input[type="checkbox"]:checked', context).each(function () {
+        vals.push($.trim($(this).next('label').text()));
+      });
+      if (!vals.length) {
+        return Drupal.t('Not restricted');
+      }
+      else if ($('input[name="googleanalytics_visibility_roles"]:checked', context).val() == 1) {
+        return Drupal.t('Excepted: @roles', {'@roles' : vals.join(', ')});
+      }
+      else {
+        return vals.join(', ');
+      }
+    });
+
+    $('fieldset#edit-user-vis-settings', context).drupalSetSummary(function (context) {
+      var $radio = $('input[name="googleanalytics_custom"]:checked', context);
+      if ($radio.val() == 0) {
+        return Drupal.t('Not customizable');
+      }
+      else if ($radio.val() == 1) {
+        return Drupal.t('On by default with opt out');
+      }
+      else {
+        return Drupal.t('Off by default with opt in');
+      }
+    });
+
+    $('fieldset#edit-linktracking', context).drupalSetSummary(function (context) {
+      var vals = [];
+      if ($('input#edit-googleanalytics-trackoutbound', context).is(':checked')) {
+        vals.push('Outbound links');
+      }
+      if ($('input#edit-googleanalytics-trackmailto', context).is(':checked')) {
+        vals.push('Mailto links');
+      }
+      if ($('input#edit-googleanalytics-trackfiles', context).is(':checked')) {
+        vals.push('Downloads');
+      }
+      if (!vals.length) {
+        return Drupal.t('Not tracked');
+      }
+      return Drupal.t('@items tracked', {'@items' : vals.join(', ')});
+    });
+
+    $('fieldset#edit-search-and-adsense', context).drupalSetSummary(function (context) {
+      var vals = [];
+      if ($('input#edit-googleanalytics-site-search', context).is(':checked')) {
+        vals.push('Site search');
+      }
+      if ($('input#edit-googleanalytics-trackadsense', context).is(':checked')) {
+        vals.push('AdSense ads');
+      }
+      if (!vals.length) {
+        return Drupal.t('Not tracked');
+      }
+      return Drupal.t('@items tracked', {'@items' : vals.join(', ')});
+    });
+
+    $('fieldset#edit-domain-tracking', context).drupalSetSummary(function (context) {
+      var $radio = $('input[name="googleanalytics_domain_mode"]:checked', context);
+      if ($radio.val() == 0) {
+        return Drupal.t('A single domain');
+      }
+      else if ($radio.val() == 1) {
+        return Drupal.t('One domain with multiple subdomains');
+      }
+      else {
+        return Drupal.t('Multiple top-level domains');
+      }
+    });
+  }
+};
+
+})(jQuery);
diff --git a/sites/all/modules/google_analytics/googleanalytics.info b/sites/all/modules/google_analytics/googleanalytics.info
new file mode 100644
index 0000000000000000000000000000000000000000..b0bd35f37915bcbe2978553481e634b615cbe831
--- /dev/null
+++ b/sites/all/modules/google_analytics/googleanalytics.info
@@ -0,0 +1,14 @@
+; $Id: googleanalytics.info,v 1.12.2.3 2011/01/02 22:01:30 hass Exp $
+name = "Google Analytics"
+description = Allows your site to be tracked by Google Analytics by adding a Javascript tracking code to every page.
+core = 7.x
+package = Statistics
+configure = admin/config/system/googleanalytics
+files[] = googleanalytics.test
+
+; Information added by drupal.org packaging script on January 1, 1970 - 00:00
+version = "7.x-1.1"
+core = "7.x"
+project = "google_analytics"
+datestamp = "1297103606"
+
diff --git a/sites/all/modules/google_analytics/googleanalytics.install b/sites/all/modules/google_analytics/googleanalytics.install
new file mode 100644
index 0000000000000000000000000000000000000000..fafba6f0ca3702af1112181773377fb1809092e6
--- /dev/null
+++ b/sites/all/modules/google_analytics/googleanalytics.install
@@ -0,0 +1,398 @@
+<?php
+// $Id: googleanalytics.install,v 1.22.2.16 2011/02/07 14:29:06 hass Exp $
+
+/**
+ * @file
+ * Installation file for Google Analytics module.
+ */
+
+/**
+ * Implements hook_install().
+ */
+function googleanalytics_install() {
+  variable_set('googleanalytics_visibility_roles', 0);
+  variable_set('googleanalytics_visibility_pages', 0);
+
+  // Remove tracking from all administrative pages, see http://drupal.org/node/34970.
+  $pages = array(
+    'admin',
+    'admin/*',
+    'user/*/*',
+    'node/add*',
+    'node/*/*',
+  );
+  variable_set('googleanalytics_pages', implode("\n", $pages));
+
+  // By German laws it's always best to enable the anonymizing of IP addresses.
+  // NOTE: If this is also an important default setting in other countries, please let us know!
+  $countries = array(
+    'DE',
+  );
+  if (in_array(variable_get('site_default_country', ''), $countries)) {
+    variable_set('googleanalytics_tracker_anonymizeip', 1);
+  }
+}
+
+/**
+ * Implements hook_uninstall().
+ */
+function googleanalytics_uninstall() {
+  variable_del('googleanalytics_account');
+  variable_del('googleanalytics_cache');
+  variable_del('googleanalytics_codesnippet_before');
+  variable_del('googleanalytics_codesnippet_after');
+  variable_del('googleanalytics_cross_domains');
+  variable_del('googleanalytics_custom');
+  variable_del('googleanalytics_custom_vars');
+  variable_del('googleanalytics_domain_mode');
+  variable_del('googleanalytics_js_scope');
+  variable_del('googleanalytics_last_cache');
+  variable_del('googleanalytics_pages');
+  variable_del('googleanalytics_roles');
+  variable_del('googleanalytics_segmentation');
+  variable_del('googleanalytics_site_search');
+  variable_del('googleanalytics_trackadsense');
+  variable_del('googleanalytics_tracker_anonymizeip');
+  variable_del('googleanalytics_trackfiles');
+  variable_del('googleanalytics_trackfiles_extensions');
+  variable_del('googleanalytics_trackmailto');
+  variable_del('googleanalytics_trackoutbound');
+  variable_del('googleanalytics_trackoutboundaspageview');
+  variable_del('googleanalytics_translation_set');
+  variable_del('googleanalytics_visibility_pages');
+  variable_del('googleanalytics_visibility_roles');
+
+  // Remove backup variables if exits. Remove this code in D8.
+  variable_del('googleanalytics_codesnippet_after_backup_6300');
+  variable_del('googleanalytics_codesnippet_before_backup_6300');
+}
+
+/**
+ * Implements hook_disable().
+ *
+ * Remove cache directory if module is disabled (or uninstalled).
+ */
+function googleanalytics_disable() {
+  googleanalytics_clear_js_cache();
+}
+
+/**
+ * Implements hook_requirements().
+ */
+function googleanalytics_requirements($phase) {
+  $requirements = array();
+  $t = get_t();
+
+  if ($phase == 'runtime') {
+    // Raise warning if Google user account has not been set yet.
+    if (!preg_match('/^UA-\d{4,}-\d+$/', variable_get('googleanalytics_account', 'UA-'))) {
+      $requirements['googleanalytics'] = array(
+        'title' => $t('Google Analytics module'),
+        'description' => $t('Google Analytics module has not been configured yet. Please configure its settings from the <a href="@url">Google Analytics settings page</a>.', array('@url' => url('admin/config/system/googleanalytics'))),
+        'severity' => REQUIREMENT_ERROR,
+        'value' => $t('Not configured'),
+      );
+    }
+  }
+
+  return $requirements;
+}
+
+/**
+ * Upgrade old extension variable to new and use old name as enabled/disabled flag.
+ */
+function googleanalytics_update_6000() {
+  variable_set('googleanalytics_trackfiles_extensions', variable_get('googleanalytics_trackfiles', '7z|aac|avi|csv|doc|exe|flv|gif|gz|jpe?g|js|mp(3|4|e?g)|mov|pdf|phps|png|ppt|rar|sit|tar|torrent|txt|wma|wmv|xls|xml|zip'));
+  $trackfiles = variable_get('googleanalytics_trackfiles', '7z|aac|avi|csv|doc|exe|flv|gif|gz|jpe?g|js|mp(3|4|e?g)|mov|pdf|phps|png|ppt|rar|sit|tar|torrent|txt|wma|wmv|xls|xml|zip') ? TRUE : FALSE;
+  variable_set('googleanalytics_trackfiles', $trackfiles);
+
+  return t('Updated download tracking file extensions.');
+}
+
+function googleanalytics_update_6001() {
+  variable_set('googleanalytics_visibility', 0);
+
+  // Remove tracking from all administrative pages, see http://drupal.org/node/34970.
+  $pages = array(
+    'admin*',
+    'user*',
+    'node/add*',
+    'node/*/*',
+  );
+  variable_set('googleanalytics_pages', implode("\n", $pages));
+
+  return t('Added page tracking to every page except the listed pages: @pages.', array('@pages' => implode(', ', $pages)));
+}
+
+/**
+ * Upgrade role settings and per user tracking settings
+ * of "User 1" and remove outdated tracking variables.
+ */
+function googleanalytics_update_6002() {
+  // Upgrade enabled/disabled roles to new logic (correct for upgrades from 5.x-1.4 and 6.x-1.0).
+  $roles = array();
+  $messages = array();
+  foreach (user_roles() as $rid => $name) {
+    if (variable_get('googleanalytics_track_' . $rid, FALSE)) {
+      // Role ID is activated for user tracking.
+      $roles[$rid] = $rid;
+      $messages[] = t('Enabled page tracking for role: @name.', array('@name' => $name));
+    }
+    else {
+      $messages[] = t('Disabled page tracking for role: @name.', array('@name' => $name));
+    }
+  }
+  variable_set('googleanalytics_roles', $roles);
+
+  // Upgrade disabled tracking of "user 1" to new logic.
+  if (!$track_user1 = variable_get('googleanalytics_track__user1', 1)) {
+    variable_set('googleanalytics_custom', 1);
+
+    // Load user 1 object, set appropriate value and save new user settings back.
+    $account = user_load(1);
+    $account = user_save($account, array('data' => array('googleanalytics' => array('custom' => 0))), 'account');
+    $messages[] = t('Disabled user specific page tracking for site administrator.');
+  }
+
+  // Delete outdated tracking settings.
+  db_delete('variable')
+    ->condition('name', db_like('googleanalytics_track_') . '%', 'LIKE')
+    ->execute();
+
+  return implode(', ', $messages);
+}
+
+/**
+ * #262468: Clear menu cache to solve stale menu data in 5.x-1.5 and 6.x-1.1
+ */
+function googleanalytics_update_6003() {
+  menu_rebuild();
+  return t('Menu has been rebuild.');
+}
+
+/**
+ * Change visibility setting for path "user/*".
+ */
+function googleanalytics_update_6004() {
+  // Original pages setting.
+  $pages = array(
+    'admin*',
+    'user*',
+    'node/add*',
+    'node/*/*',
+  );
+
+  $diff = array_diff($pages, preg_split('/(\r\n?|\n)/', variable_get('googleanalytics_pages', implode("\n", $pages))));
+  if (empty($diff)) {
+    // No diff to original settings found. Update with new settings.
+    $pages = array(
+      'admin*',
+      'user/*/*',
+      'node/add*',
+      'node/*/*',
+    );
+    variable_set('googleanalytics_pages', implode("\n", $pages));
+    return t('Path visibility filter setting changed from "user*" to "user/*/*".');
+  }
+  else {
+    return t('Custom path visibility filter setting found. Update skipped!');
+  }
+}
+
+/**
+ * Change visibility setting for path "admin*".
+ */
+function googleanalytics_update_6005() {
+  // Original pages setting.
+  $pages = array(
+    'admin*',
+    'user/*/*',
+    'node/add*',
+    'node/*/*',
+  );
+
+  $diff = array_diff($pages, preg_split('/(\r\n?|\n)/', variable_get('googleanalytics_pages', implode("\n", $pages))));
+  if (empty($diff)) {
+    // No diff to original settings found. Update with new settings.
+    $pages = array(
+      'admin',
+      'admin/*',
+      'user/*/*',
+      'node/add*',
+      'node/*/*',
+    );
+    variable_set('googleanalytics_pages', implode("\n", $pages));
+    return t('Path visibility filter setting changed from "admin*" to "admin" and "admin/*".');
+  }
+  else {
+    return t('Custom path visibility filter setting found. Update skipped!');
+  }
+}
+
+/**
+ * Upgrade custom javascript settings.
+ */
+function googleanalytics_update_6006() {
+  variable_set('googleanalytics_codesnippet_before', variable_get('googleanalytics_codesnippet', ''));
+  variable_del('googleanalytics_codesnippet');
+
+  return t('Upgraded custom javascript codesnippet setting.');
+}
+
+/**
+ * Remove "User identifier" and "User name" from segmentation fields.
+ *
+ * This is a data protection and privacy law change. For more information see Google Analytics
+ * terms of use section 8.1 (http://www.google.com/analytics/en-GB/tos.html).
+ */
+function googleanalytics_update_6007() {
+  $profile_fields = variable_get('googleanalytics_segmentation', array());
+  unset($profile_fields['uid']);
+  unset($profile_fields['name']);
+  variable_set('googleanalytics_segmentation', $profile_fields);
+
+  return t('Removed "User identifier" and "User name" from segmentation fields.');
+}
+
+/**
+ * Remove outdated legacy support variables and files.
+ */
+function googleanalytics_update_6200() {
+  $path = 'public://googleanalytics';
+  if (file_exists($path)) {
+    file_unmanaged_delete($path . '/urchin.js');
+  }
+  variable_del('googleanalytics_legacy_version');
+
+  return t('Removed outdated legacy tracker stuff.');
+}
+
+/**
+ * Update list of default file extensions.
+ */
+function googleanalytics_update_6201() {
+  if (variable_get('googleanalytics_trackfiles_extensions', '') == '7z|aac|avi|csv|doc|exe|flv|gif|gz|jpe?g|js|mp(3|4|e?g)|mov|pdf|phps|png|ppt|rar|sit|tar|torrent|txt|wma|wmv|xls|xml|zip') {
+    variable_set('googleanalytics_trackfiles_extensions', '7z|aac|arc|arj|asf|asx|avi|bin|csv|doc|exe|flv|gif|gz|gzip|hqx|jar|jpe?g|js|mp(2|3|4|e?g)|mov(ie)?|msi|msp|pdf|phps|png|ppt|qtm?|ra(m|r)?|sea|sit|tar|tgz|torrent|txt|wav|wma|wmv|wpd|xls|xml|z|zip');
+  }
+
+  return t('The default extensions for download tracking have been updated.');
+}
+
+/**
+ * Try to update Google Analytics custom code snippet to async version.
+ */
+function googleanalytics_update_6300() {
+  $messages = array();
+
+  // TODO: Backup synchronous code snippets. Remove variables in D8.
+  variable_set('googleanalytics_codesnippet_before_backup_6300', variable_get('googleanalytics_codesnippet_before', ''));
+  variable_set('googleanalytics_codesnippet_after_backup_6300', variable_get('googleanalytics_codesnippet_after', ''));
+
+  // Upgrade of BEFORE code snippet.
+  $code_before = variable_get('googleanalytics_codesnippet_before', '');
+  if (!empty($code_before)) {
+    // No value, e.g. _setLocalRemoteServerMode()
+    $code_before = preg_replace('/(.*)pageTracker\.(\w+)\(\);(.*)/i', '$1_gaq.push(["$2"]);$3', $code_before);
+    // One value, e.g. _setCookiePath()
+    $code_before = preg_replace('/(.*)pageTracker\.(\w+)\(("|\'?)(\w+)("|\'?)\);(.*)/i', '$1_gaq.push(["$2", $3$4$5]);$6', $code_before);
+    // Multiple values e.g. _trackEvent()
+    $code_before = preg_replace('/(.*)pageTracker\.(\w+)\((.*)\);(.*)/i', '$1_gaq.push(["$2", $3]);$4', $code_before);
+
+    variable_set('googleanalytics_codesnippet_before', $code_before);
+
+    drupal_set_message(Database::getConnection()->prefixTables("<strong>Attempted</strong> to upgrade Google Analytics custom 'before' code snippet. Backup of previous code snippet has been saved in database table '{variable}' as 'googleanalytics_codesnippet_before_backup_6300'. Please consult Google's <a href='http://code.google.com/intl/de-DE/apis/analytics/docs/tracking/asyncUsageGuide.html'>Asynchronous Tracking Usage Guide</a> if the upgrade was successfully."), 'warning');
+    $messages[] = t('Upgraded custom "before" code snippet.');
+  }
+
+  // Upgrade of AFTER code snippet.
+  // We cannot update this code snippet automatically. Show message that the upgrade has been skipped.
+  $code_after = variable_get('googleanalytics_codesnippet_after', '');
+  if (!empty($code_after)) {
+    drupal_set_message(Database::getConnection()->prefixTables("Automatic upgrade of Google Analytics custom 'after' code snippet has been skipped. Backup of previous code snippet has been saved in database table '{variable}' as 'googleanalytics_codesnippet_after_backup_6300'. You need to manually upgrade the custom 'after' code snippet."), 'error');
+    $messages[] = t('Skipped custom "after" code snippet.');
+  }
+
+  return empty($messages) ? t('No custom code snipped found. Nothing to do.') : implode(' ', $messages);
+}
+
+/**
+ * Run D6 -> D7 upgrades.
+ */
+function googleanalytics_update_7000() {
+  // Update JavaScript scope to 'header'.
+  variable_set('googleanalytics_js_scope', 'header');
+  $messages[] = t('Google tracking code has been moved to header.');
+
+  // Upgrade D6 token placeholder to D7. update_6301 is not required.
+  $googleanalytics_custom_vars = variable_get('googleanalytics_custom_var', array());
+  if (!empty($googleanalytics_custom_vars['slots'][1]) && $googleanalytics_custom_vars['slots'][1]['name'] == 'User roles' && $googleanalytics_custom_vars['slots'][1]['value'] = '[user-role-names]') {
+    $googleanalytics_custom_vars['slots'][1]['value'] = '[current-user:role-names]';
+    variable_set('googleanalytics_custom_var', $googleanalytics_custom_vars);
+    $messages[] = t("The D6 token placeholder [user-role-names] used in the custom variable 'User roles' has been replaced with [current-user:role-names].");
+  }
+
+  return implode(' ', $messages);
+}
+
+/**
+ * Automatically enable anonymizing of IP addresses for Germany.
+ */
+function googleanalytics_update_7001() {
+  // By German law it's always best to enable the anonymizing of IP addresses.
+  $countries = array(
+    'DE',
+  );
+  if (in_array(variable_get('site_default_country', ''), $countries)) {
+    variable_set('googleanalytics_tracker_anonymizeip', 1);
+    return t('The default country in your regional settings is Germany. Anonymizing of IP addresses has been enabled for privacy reasons.');
+  }
+  else {
+    return t('The default country in your regional settings is <em>not</em> Germany. The anonymizing of IP addresses setting has not been changed. Make sure your site settings comply with the local privacy rules.');
+  }
+}
+
+/**
+ * Upgrade "User roles" tracking to custom variables.
+ */
+function googleanalytics_update_7002() {
+
+  // Read previous segmentation settings.
+  $segmentation = variable_get('googleanalytics_segmentation', array());
+
+  // If this is an upgrade from D6 the slot 1 may not empty.
+  if (empty($googleanalytics_custom_vars['slots'][1]) && in_array('roles', $segmentation)) {
+    // Upgrade previous segmentation settings to new custom variables settings.
+    $googleanalytics_custom_vars = variable_get('googleanalytics_custom_var', array());
+
+    $googleanalytics_custom_vars['slots'][1]['slot'] = 1;
+    $googleanalytics_custom_vars['slots'][1]['name'] = 'User roles';
+    $googleanalytics_custom_vars['slots'][1]['value'] = '[current-user:role-names]';
+    $googleanalytics_custom_vars['slots'][1]['scope'] = 1; // Sets the scope to visitor-level.
+
+    variable_set('googleanalytics_custom_var', $googleanalytics_custom_vars);
+    return t('The deprecated profile segmentation setting for "User roles" has been added to custom variables. You need to deselect all selected profile fields in <a href="@admin">Google Analytics settings</a> and upgrade other profile fields manually or you may loose tracking data in future! See Google Analytics <a href="@customvar">Custom Variables</a> for more information.', array('@customvar' => 'http://code.google.com/intl/en/apis/analytics/docs/tracking/gaTrackingCustomVariables.html', '@admin' => url('admin/config/system/googleanalytics')));
+  }
+  else {
+    return t('You need to deselect all selected profile fields in <a href="@admin">Google Analytics settings</a> and upgrade other profile fields manually or you may loose tracking data in future! See Google Analytics <a href="@customvar">Custom Variables</a> for more information.', array('@customvar' => 'http://code.google.com/intl/en/apis/analytics/docs/tracking/gaTrackingCustomVariables.html', '@admin' => url('admin/config/system/googleanalytics')));
+  }
+}
+
+/**
+ * Rename googleanalytics_trackoutgoing variable to googleanalytics_trackoutbound.
+ */
+function googleanalytics_update_7003() {
+  variable_set('googleanalytics_trackoutbound', variable_get('googleanalytics_trackoutgoing', 1));
+  variable_del('googleanalytics_trackoutgoing');
+
+  return t('Renamed "googleanalytics_trackoutgoing" settings variable to googleanalytics_trackoutbound.');
+}
+
+/**
+ * Rename googleanalytics_visibility variable to googleanalytics_visibility_pages for consistency.
+ */
+function googleanalytics_update_7004() {
+  variable_set('googleanalytics_visibility_pages', variable_get('googleanalytics_visibility', 1));
+  variable_del('googleanalytics_visibility');
+
+  return t('Renamed "googleanalytics_visibility" settings variable to googleanalytics_visibility_pages.');
+}
diff --git a/sites/all/modules/google_analytics/googleanalytics.js b/sites/all/modules/google_analytics/googleanalytics.js
new file mode 100644
index 0000000000000000000000000000000000000000..3e8ca35a0f004e8025fdeca8ac13a01c3d20d3b0
--- /dev/null
+++ b/sites/all/modules/google_analytics/googleanalytics.js
@@ -0,0 +1,77 @@
+// $Id: googleanalytics.js,v 1.11.2.8 2011/02/06 19:22:05 hass Exp $
+(function ($) {
+
+$(document).ready(function() {
+
+  // Accepts a string; returns the string with regex metacharacters escaped. The returned string
+  // can safely be used at any point within a regex to match the provided literal string. Escaped
+  // characters are [ ] { } ( ) * + ? - . , \ ^ $ # and whitespace. The character | is excluded
+  // in this function as it's used to separate the domains names.
+  RegExp.escapeDomains = function(text) {
+    return text.replace(/[-[\]{}()*+?.,\\^$#\s]/g, "\\$&");
+  }
+
+  // Attach onclick event to document only and catch clicks on all elements.
+  $(document.body).click(function(event) {
+    // Catch only the first parent link of a clicked element.
+    $(event.target).parents("a:first,area:first").andSelf().filter("a,area").each(function() {
+
+      var ga = Drupal.settings.googleanalytics;
+      // Expression to check for absolute internal links.
+      var isInternal = new RegExp("^(https?):\/\/" + window.location.host, "i");
+      // Expression to check for special links like gotwo.module /go/* links.
+      var isInternalSpecial = new RegExp("(\/go\/.*)$", "i");
+      // Expression to check for download links.
+      var isDownload = new RegExp("\\.(" + ga.trackDownloadExtensions + ")$", "i");
+      // Expression to check for the sites cross domains.
+      var isCrossDomain = new RegExp("^(https?|ftp|news|nntp|telnet|irc|ssh|sftp|webcal):\/\/.*(" + RegExp.escapeDomains(ga.trackCrossDomains) + ")", "i");
+
+      // Is the clicked URL internal?
+      if (isInternal.test(this.href)) {
+        // Is download tracking activated and the file extension configured for download tracking?
+        if (ga.trackDownload && isDownload.test(this.href)) {
+          // Download link clicked.
+          var extension = isDownload.exec(this.href);
+          _gaq.push(["_trackEvent", "Downloads", extension[1].toUpperCase(), this.href.replace(isInternal, '')]);
+        }
+        else if (isInternalSpecial.test(this.href)) {
+          // Keep the internal URL for Google Analytics website overlay intact.
+          _gaq.push(["_trackPageview", this.href.replace(isInternal, '')]);
+          setTimeout('document.location = "' + this.href + '"', 100);
+        }
+      }
+      else {
+        if (ga.trackMailto && $(this).is("a[href^=mailto:],area[href^=mailto:]")) {
+          // Mailto link clicked.
+          _gaq.push(["_trackEvent", "Mails", "Click", this.href.substring(7)]);
+        }
+        else if (ga.trackOutbound && this.href) {
+          if (ga.trackDomainMode == 2 && isCrossDomain.test(this.href)) {
+            // Top-level cross domain clicked.
+            _gaq.push(["_link", this.href]);
+          }
+          else if (ga.trackOutboundAsPageview) {
+            // Track all external links as page views after URL cleanup.
+            // Currently required, if click should be tracked as goal.
+            _gaq.push(["_trackPageview", '/outbound/' + this.href.replace(/^(https?|ftp|news|nntp|telnet|irc|ssh|sftp|webcal):\/\//i, '').split('/').join('--')]);
+            setTimeout('document.location = "' + this.href + '"', 100);
+          }
+          else {
+            // External link clicked.
+            _gaq.push(["_trackEvent", "Outbound links", "Click", this.href]);
+
+            // First, delay the outbound click by a fraction of a second.
+            // This delay will hardly be noticeable by the user, but it will provide the
+            // browser more time load the tracking code. Without this method, it's possible
+            // that a user can click on the outbound link before the tracking code loads,
+            // in which case the event will not be recorded.
+            // See http://www.google.com/support/analytics/bin/answer.py?hl=en&answer=55527
+            setTimeout('document.location = "' + this.href + '"', 100);
+          }
+        }
+      }
+    });
+  });
+});
+
+})(jQuery);
diff --git a/sites/all/modules/google_analytics/googleanalytics.module b/sites/all/modules/google_analytics/googleanalytics.module
new file mode 100644
index 0000000000000000000000000000000000000000..a00c2ff49738c6ad9c41e908931691b0e758f51c
--- /dev/null
+++ b/sites/all/modules/google_analytics/googleanalytics.module
@@ -0,0 +1,535 @@
+<?php
+// $Id: googleanalytics.module,v 1.70.2.13 2011/02/07 17:30:49 hass Exp $
+
+/*
+ * @file
+ * Drupal Module: GoogleAnalytics
+ * Adds the required Javascript to the bottom of all your Drupal pages
+ * to allow tracking by the Google Analytics statistics package.
+ *
+ * @author: Alexander Hass <http://drupal.org/user/85918>
+ */
+
+define('GA_TRACKFILES_EXTENSIONS', '7z|aac|arc|arj|asf|asx|avi|bin|csv|doc|exe|flv|gif|gz|gzip|hqx|jar|jpe?g|js|mp(2|3|4|e?g)|mov(ie)?|msi|msp|pdf|phps|png|ppt|qtm?|ra(m|r)?|sea|sit|tar|tgz|torrent|txt|wav|wma|wmv|wpd|xls|xml|z|zip');
+
+/**
+ * Implements hook_help().
+ */
+function googleanalytics_help($path, $arg) {
+  switch ($path) {
+    case 'admin/config/system/googleanalytics':
+      return t('<a href="@ga_url">Google Analytics</a> is a free (registration required) website traffic and marketing effectiveness service.', array('@ga_url' => 'http://www.google.com/analytics/'));
+  }
+}
+
+/**
+ * Implements hook_theme().
+ */
+function googleanalytics_theme() {
+  return array(
+    'googleanalytics_admin_custom_var_table' => array(
+      'render element' => 'form',
+    ),
+  );
+}
+
+/**
+ * Implements hook_permission().
+ */
+function googleanalytics_permission() {
+  return array(
+    'administer google analytics' => array(
+      'title' => t('Administer Google Analytics'),
+      'description' => t('Perform maintenance tasks for Google Analytics.'),
+    ),
+    'opt-in or out of tracking' => array(
+      'title' => t('Opt-in or out of tracking'),
+      'description' => t('Allow users to decide if tracking code will be added to pages or not.'),
+    ),
+    'use PHP for tracking visibility' => array(
+      'title' => t('Use PHP for tracking visibility'),
+      'description' => t('Enter PHP code in the field for tracking visibility settings. %warning', array('%warning' => t('Warning: Give to trusted roles only; this permission has security implications.'))),
+    ),
+  );
+}
+
+/**
+ * Implements hook_menu().
+ */
+function googleanalytics_menu() {
+  $items['admin/config/system/googleanalytics'] = array(
+    'title' => 'Google Analytics',
+    'description' => 'Configure tracking behavior to get insights into your website traffic and marketing effectiveness.',
+    'page callback' => 'drupal_get_form',
+    'page arguments' => array('googleanalytics_admin_settings_form'),
+    'access arguments' => array('administer google analytics'),
+    'type' => MENU_NORMAL_ITEM,
+    'file' => 'googleanalytics.admin.inc',
+  );
+
+  return $items;
+}
+
+/**
+ * Implements hook_page_alter() to insert JavaScript to the appropriate scope/region of the page.
+ */
+function googleanalytics_page_alter(&$page) {
+  global $user;
+
+  $id = variable_get('googleanalytics_account', '');
+
+  // Get page status code for visibility filtering.
+  $status = drupal_get_http_header('Status');
+  $trackable_status_codes = array(
+    '403 Forbidden',
+    '404 Not Found',
+  );
+
+  // 1. Check if the GA account number has a value.
+  // 2. Track page views based on visibility value.
+  // 3. Check if we should track the currently active user's role.
+  // 4. Ignore pages visibility filter for 404 or 403 status codes.
+  if (!empty($id) && (_googleanalytics_visibility_pages() || in_array($status, $trackable_status_codes)) && _googleanalytics_visibility_user($user)) {
+
+    // We allow different scopes. Default to 'header' but allow user to override if they really need to.
+    $scope = variable_get('googleanalytics_js_scope', 'header');
+
+    if (variable_get('googleanalytics_trackadsense', FALSE)) {
+      // Custom tracking. Prepend before all other JavaScript.
+      drupal_add_js('window.google_analytics_uacct = ' . drupal_json_encode($id) . ';', array('type' => 'inline', 'group' => JS_LIBRARY-1));
+    }
+
+    // Add link tracking.
+    $link_settings = array();
+    if ($track_outbound = variable_get('googleanalytics_trackoutbound', 1)) {
+      $link_settings['trackOutbound'] = $track_outbound;
+    }
+    if ($track_mailto = variable_get('googleanalytics_trackmailto', 1)) {
+      $link_settings['trackMailto'] = $track_mailto;
+    }
+    if (($track_download = variable_get('googleanalytics_trackfiles', 1)) && ($trackfiles_extensions = variable_get('googleanalytics_trackfiles_extensions', GA_TRACKFILES_EXTENSIONS))) {
+      $link_settings['trackDownload'] = $track_download;
+      $link_settings['trackDownloadExtensions'] = $trackfiles_extensions;
+    }
+    if ($track_outbound_as_pageview = variable_get('googleanalytics_trackoutboundaspageview', 0)) {
+      $link_settings['trackOutboundAsPageview'] = $track_outbound_as_pageview;
+    }
+    if ($track_domain_mode = variable_get('googleanalytics_domain_mode', 0)) {
+      $link_settings['trackDomainMode'] = $track_domain_mode;
+    }
+    if ($track_cross_domains = variable_get('googleanalytics_cross_domains', '')) {
+      $domains = preg_split('/(\r\n?|\n)/', $track_cross_domains);
+      $link_settings['trackCrossDomains'] = implode('|', $domains);
+    }
+
+    if (!empty($link_settings)) {
+      drupal_add_js(array('googleanalytics' => $link_settings), 'setting');
+      drupal_add_js(drupal_get_path('module', 'googleanalytics') . '/googleanalytics.js');
+    }
+
+    // Add User profile segmentation values.
+    $profile_fields = variable_get('googleanalytics_segmentation', array());
+    if (!empty($profile_fields)) {
+      // Invoke all modules having a hook_user_load() implemented.
+      // If the invoked modules extend the $user object, the additional
+      // data can be tracked.
+      module_invoke_all('user_load', array($user->uid => $user));
+
+      $fields = array();
+      foreach ($profile_fields as $field => $title) {
+        $fields[$field] = is_array($user->$field) ? implode(',', $user->$field) : $user->$field;
+      }
+
+      // Only show segmentation variable if there are specified fields.
+      $segmentation = '';
+      if (count($fields) > 0) {
+        $segmentation = '_gaq.push(["_setVar", ' . drupal_json_encode(implode(':', $fields)) . ']);';
+      }
+    }
+
+    // Site search tracking support.
+    $url_custom = '';
+    if (module_exists('search') && variable_get('googleanalytics_site_search', FALSE) && arg(0) == 'search' && $keys = googleanalytics_search_get_keys()) {
+      $url_custom = drupal_json_encode(rawurldecode(url('search/' . arg(1), array('query' => array('search' => $keys)))));
+    }
+
+    // If this node is a translation of another node, pass the original
+    // node instead.
+    if (module_exists('translation') && variable_get('googleanalytics_translation_set', 0)) {
+      // Check we have a node object, it supports translation, and its
+      // translated node ID (tnid) doesn't match its own node ID.
+      $node = menu_get_object();
+      if ($node && translation_supported_type($node->type) && isset($node->tnid) && ($node->tnid != $node->nid)) {
+        $source_node = node_load($node->tnid);
+        $languages = language_list();
+        $url_custom = drupal_json_encode(url('node/' . $source_node->nid, array('language' => $languages[$source_node->language])));
+      }
+    }
+
+    // Track access denied (403) and file not found (404) pages.
+    if ($status == '403 Forbidden') {
+      // See http://www.google.com/support/analytics/bin/answer.py?answer=86927
+      $url_custom = '"/403.html?page=" + document.location.pathname + document.location.search + "&from=" + document.referrer';
+    }
+    elseif ($status == '404 Not Found') {
+      $url_custom = '"/404.html?page=" + document.location.pathname + document.location.search + "&from=" + document.referrer';
+    }
+
+    // Add any custom code snippets if specified.
+    $codesnippet_before = variable_get('googleanalytics_codesnippet_before', '');
+    $codesnippet_after = variable_get('googleanalytics_codesnippet_after', '');
+
+    // Add custom variables.
+    $googleanalytics_custom_vars = variable_get('googleanalytics_custom_var', array());
+    $custom_var = '';
+    for ($i = 1; $i < 6; $i++) {
+      $custom_var_name = !empty($googleanalytics_custom_vars['slots'][$i]['name']) ? $googleanalytics_custom_vars['slots'][$i]['name'] : '';
+      if (!empty($custom_var_name)) {
+        $custom_var_value = !empty($googleanalytics_custom_vars['slots'][$i]['value']) ? $googleanalytics_custom_vars['slots'][$i]['value'] : '';
+        $custom_var_scope = !empty($googleanalytics_custom_vars['slots'][$i]['scope']) ? $googleanalytics_custom_vars['slots'][$i]['scope'] : 3;
+
+        $node = menu_get_object();
+        $custom_var_value = token_replace($custom_var_value, array('node' => $node), array('clear' => TRUE));
+
+        // Suppress empty custom variables.
+        if (!is_numeric($custom_var_value) && empty($custom_var_value)) {
+          continue;
+        }
+
+        // The length of the string used for the 'name' and the length of the
+        // string used for the 'value' must not exceed 64 bytes after url encoding.
+        $name_length = drupal_strlen(rawurlencode($custom_var_name));
+        $tmp_value = rawurlencode($custom_var_value);
+        $value_length = drupal_strlen($tmp_value);
+        if ($name_length + $value_length > 64) {
+          // Trim value and remove fragments of url encoding.
+          $tmp_value = rtrim(substr($tmp_value, 0, 63 - $name_length), '%0..9A..F');
+          $custom_var_value = urldecode($tmp_value);
+        }
+
+        $custom_var_name = drupal_json_encode($custom_var_name);
+        $custom_var_value = drupal_json_encode($custom_var_value);
+        $custom_var .= "_gaq.push(['_setCustomVar', $i, $custom_var_name, $custom_var_value, $custom_var_scope]);";
+      }
+    }
+
+    // Build tracker code.
+    $script = 'var _gaq = _gaq || [];';
+    $script .= '_gaq.push(["_setAccount", ' . drupal_json_encode($id) . ']);';
+    if (variable_get('googleanalytics_tracker_anonymizeip', 0)) {
+      // FIXME: The Google API is currently broken and "_gat._anonymizeIp" is only
+      // a workaround until "_anonymizeIp" has been implemented/fixed.
+      $script .= '_gaq.push(["_gat._anonymizeIp"]);';
+    }
+
+    // Domain tracking type.
+    global $cookie_domain;
+    $domain_mode = variable_get('googleanalytics_domain_mode', 0);
+
+    // Per RFC 2109, cookie domains must contain at least one dot other than the
+    // first. For hosts such as 'localhost' or IP Addresses we don't set a cookie domain.
+    if ($domain_mode == 1 && count(explode('.', $cookie_domain)) > 2 && !is_numeric(str_replace('.', '', $cookie_domain))) {
+      $script .= '_gaq.push(["_setDomainName", ' . drupal_json_encode($cookie_domain) . ']);';
+    }
+    elseif ($domain_mode == 2) {
+      $script .= '_gaq.push(["_setDomainName", "none"]);';
+      $script .= '_gaq.push(["_setAllowLinker", true]);';
+    }
+
+    if (!empty($segmentation)) {
+      $script .= $segmentation;
+    }
+    if (!empty($codesnippet_before)) {
+      $script .= $codesnippet_before;
+    }
+    if (!empty($custom_var)) {
+      $script .= $custom_var;
+    }
+    if (empty($url_custom)) {
+      $script .= '_gaq.push(["_trackPageview"]);';
+    }
+    else {
+      $script .= '_gaq.push(["_trackPageview", ' . $url_custom . ']);';
+    }
+    if (!empty($codesnippet_after)) {
+      $script .= $codesnippet_after;
+    }
+
+    $script .= '(function() {';
+    $script .= 'var ga = document.createElement("script");';
+    $script .= 'ga.type = "text/javascript";';
+    $script .= 'ga.async = true;';
+
+    // Should a local cached copy of ga.js be used?
+    if (variable_get('googleanalytics_cache', 0) && $url = _googleanalytics_cache('http://www.google-analytics.com/ga.js')) {
+      // A dummy query-string is added to filenames, to gain control over
+      // browser-caching. The string changes on every update or full cache
+      // flush, forcing browsers to load a new copy of the files, as the
+      // URL changed.
+      $query_string = '?' . variable_get('css_js_query_string', '0');
+
+      $script .= 'ga.src = "' . $url . $query_string . '";';
+    }
+    else {
+      $script .= 'ga.src = ("https:" == document.location.protocol ? "https://ssl" : "http://www") + ".google-analytics.com/ga.js";';
+    }
+    $script .= 'var s = document.getElementsByTagName("script")[0];';
+    $script .= 's.parentNode.insertBefore(ga, s);';
+    $script .= '})();';
+
+    drupal_add_js($script, array('scope' => $scope, 'type' => 'inline'));
+  }
+}
+
+/**
+ * Implements hook_form_FORM_ID_alter().
+ *
+ * Allow users to decide if tracking code will be added to pages or not.
+ */
+function googleanalytics_form_user_profile_form_alter(&$form, &$form_state) {
+  $account = $form['#user'];
+  $category = $form['#user_category'];
+
+  if ($category == 'account' && user_access('opt-in or out of tracking') && ($custom = variable_get('googleanalytics_custom', 0)) != 0 && _googleanalytics_visibility_roles($account)) {
+    $form['googleanalytics'] = array(
+      '#type' => 'fieldset',
+      '#title' => t('Google Analytics configuration'),
+      '#weight' => 3,
+      '#collapsible' => TRUE,
+      '#tree' => TRUE
+    );
+
+    switch ($custom) {
+      case 1:
+        $description = t('Users are tracked by default, but you are able to opt out.');
+        break;
+
+      case 2:
+        $description = t('Users are <em>not</em> tracked by default, but you are able to opt in.');
+        break;
+    }
+
+    $form['googleanalytics']['custom'] = array(
+      '#type' => 'checkbox',
+      '#title' => t('Enable user tracking'),
+      '#description' => $description,
+      '#default_value' => isset($account->data['googleanalytics']['custom']) ? $account->data['googleanalytics']['custom'] : ($custom == 1)
+    );
+
+    return $form;
+  }
+}
+
+/**
+ * Implements hook_user_presave().
+ */
+function googleanalytics_user_presave(&$edit, $account, $category) {
+  if (isset($edit['googleanalytics']['custom'])) {
+    $edit['data']['googleanalytics']['custom'] = $edit['googleanalytics']['custom'];
+  }
+}
+
+/**
+ * Implements hook_cron().
+ */
+function googleanalytics_cron() {
+  // Regenerate the tracking code file every day.
+  if (REQUEST_TIME - variable_get('googleanalytics_last_cache', 0) >= 86400 && variable_get('googleanalytics_cache', 0)) {
+    _googleanalytics_cache('http://www.google-analytics.com/ga.js', TRUE);
+    variable_set('googleanalytics_last_cache', REQUEST_TIME);
+  }
+}
+
+/**
+ * Download/Synchronize/Cache tracking code file locally.
+ *
+ * @param $location
+ *   The full URL to the external javascript file.
+ * @param $sync_cached_file
+ *   Synchronize tracking code and update if remote file have changed.
+ * @return mixed
+ *   The path to the local javascript file on success, boolean FALSE on failure.
+ */
+function _googleanalytics_cache($location, $sync_cached_file = FALSE) {
+  $path = 'public://googleanalytics';
+  $file_destination = $path . '/' . basename($location);
+
+  if (!file_exists($file_destination) || $sync_cached_file) {
+    // Download the latest tracking code.
+    $result = drupal_http_request($location);
+
+    if ($result->code == 200) {
+      if (file_exists($file_destination)) {
+        // Synchronize tracking code and and replace local file if outdated.
+        $data_hash_local = drupal_hash_base64(file_get_contents($file_destination));
+        $data_hash_remote = drupal_hash_base64($result->data);
+        // Check that the files directory is writable.
+        if ($data_hash_local != $data_hash_remote && file_prepare_directory($path)) {
+          // Save updated tracking code file to disk.
+          file_unmanaged_save_data($result->data, $file_destination, FILE_EXISTS_REPLACE);
+          watchdog('googleanalytics', 'Locally cached tracking code file has been updated.', array(), WATCHDOG_INFO);
+
+          // Change query-strings on css/js files to enforce reload for all users.
+          _drupal_flush_css_js();
+        }
+      }
+      else {
+        // Check that the files directory is writable.
+        if (file_prepare_directory($path, FILE_CREATE_DIRECTORY)) {
+          // There is no need to flush JS here as core refreshes JS caches
+          // automatically, if new files are added.
+          file_unmanaged_save_data($result->data, $file_destination, FILE_EXISTS_REPLACE);
+          watchdog('googleanalytics', 'Locally cached tracking code file has been saved.', array(), WATCHDOG_INFO);
+
+          // Return the local JS file path.
+          return file_create_url($file_destination);
+        }
+      }
+    }
+  }
+  else {
+    // Return the local JS file path.
+    return file_create_url($file_destination);
+  }
+}
+
+/**
+ * Delete cached files and directory.
+ */
+function googleanalytics_clear_js_cache() {
+  $path = 'public://googleanalytics';
+  if (file_prepare_directory($path)) {
+    file_scan_directory($path, '/.*/', array('callback' => 'file_unmanaged_delete'));
+    drupal_rmdir($path);
+
+    // Change query-strings on css/js files to enforce reload for all users.
+    _drupal_flush_css_js();
+
+    watchdog('googleanalytics', 'Local cache has been purged.', array(), WATCHDOG_INFO);
+  }
+}
+
+/**
+ * Helper function for grabbing search keys. Function is missing in D7.
+ *
+ * http://api.drupal.org/api/function/search_get_keys/6
+ */
+function googleanalytics_search_get_keys() {
+  static $return;
+  if (!isset($return)) {
+    // Extract keys as remainder of path
+    // Note: support old GET format of searches for existing links.
+    $path = explode('/', $_GET['q'], 3);
+    $keys = empty($_REQUEST['keys']) ? '' : $_REQUEST['keys'];
+    $return = count($path) == 3 ? $path[2] : $keys;
+  }
+  return $return;
+}
+
+/**
+ * Tracking visibility check for an user object.
+ *
+ * @param $account
+ *   A user object containing an array of roles to check.
+ * @return boolean
+ *   A decision on if the current user is being tracked by Google Analytics.
+ */
+function _googleanalytics_visibility_user($account) {
+
+  $enabled = FALSE;
+
+  // Is current user a member of a role that should be tracked?
+  if (_googleanalytics_visibility_roles($account)) {
+
+    // Use the user's block visibility setting, if necessary.
+    if (($custom = variable_get('googleanalytics_custom', 0)) != 0) {
+      if ($account->uid && isset($account->data['googleanalytics']['custom'])) {
+        $enabled = $account->data['googleanalytics']['custom'];
+      }
+      else {
+        $enabled = ($custom == 1);
+      }
+    }
+    else {
+      $enabled = TRUE;
+    }
+
+  }
+
+  return $enabled;
+}
+
+/**
+ * Based on visibility setting this function returns TRUE if GA code should
+ * be added for the current role and otherwise FALSE.
+ */
+function _googleanalytics_visibility_roles($account) {
+
+  $visibility = variable_get('googleanalytics_visibility_roles', 0);
+  $enabled = $visibility;
+  $roles = variable_get('googleanalytics_roles', array());
+
+  if (array_sum($roles) > 0) {
+    // One or more roles are selected.
+    foreach (array_keys($account->roles) as $rid) {
+      // Is the current user a member of one of these roles?
+      if (isset($roles[$rid]) && $rid == $roles[$rid]) {
+        // Current user is a member of a role that should be tracked/excluded from tracking.
+        $enabled = !$visibility;
+        break;
+      }
+    }
+  }
+  else {
+    // No role is selected for tracking, therefore all roles should be tracked.
+    $enabled = TRUE;
+  }
+
+  return $enabled;
+}
+
+/**
+ * Based on visibility setting this function returns TRUE if GA code should
+ * be added to the current page and otherwise FALSE.
+ */
+function _googleanalytics_visibility_pages() {
+  static $page_match;
+
+  // Cache visibility result if function is called more than once.
+  if (!isset($page_match)) {
+
+    $visibility = variable_get('googleanalytics_visibility_pages', 0);
+    $setting_pages = variable_get('googleanalytics_pages', '');
+
+    // Match path if necessary.
+    if (!empty($setting_pages)) {
+      // Convert path to lowercase. This allows comparison of the same path
+      // with different case. Ex: /Page, /page, /PAGE.
+      $pages = drupal_strtolower($setting_pages);
+      if ($visibility < 2) {
+        // Convert the Drupal path to lowercase
+        $path = drupal_strtolower(drupal_get_path_alias($_GET['q']));
+        // Compare the lowercase internal and lowercase path alias (if any).
+        $page_match = drupal_match_path($path, $pages);
+        if ($path != $_GET['q']) {
+          $page_match = $page_match || drupal_match_path($_GET['q'], $pages);
+        }
+        // When $visibility has a value of 0, the tracking code is displayed on
+        // all pages except those listed in $pages. When set to 1, it
+        // is displayed only on those pages listed in $pages.
+        $page_match = !($visibility xor $page_match);
+      }
+      elseif (module_exists('php')) {
+        $page_match = php_eval($setting_pages);
+      }
+      else {
+        $page_match = FALSE;
+      }
+    }
+    else {
+      $page_match = TRUE;
+    }
+
+  }
+  return $page_match;
+}
diff --git a/sites/all/modules/google_analytics/googleanalytics.test b/sites/all/modules/google_analytics/googleanalytics.test
new file mode 100644
index 0000000000000000000000000000000000000000..22d3f3b59320a3255586936c8bc34a181c753baa
--- /dev/null
+++ b/sites/all/modules/google_analytics/googleanalytics.test
@@ -0,0 +1,256 @@
+<?php
+// $Id: googleanalytics.test,v 1.2.2.8 2011/02/07 14:11:43 hass Exp $
+
+/**
+ * @file
+ * Test file for Google Analytics module.
+ */
+class GoogleAnalyticsBasicTest extends DrupalWebTestCase {
+
+  public static function getInfo() {
+    return array(
+      'name' => t('Google Analytics basic tests'),
+      'description' => t('Test basic functionality of Google Analytics module.'),
+      'group' => 'Google Analytics',
+    );
+  }
+
+  function setUp() {
+    parent::setUp('googleanalytics');
+
+    $permissions = array(
+      'access administration pages',
+      'administer google analytics',
+    );
+
+    // User to set up google_analytics.
+    $this->admin_user = $this->drupalCreateUser($permissions);
+    $this->drupalLogin($this->admin_user);
+  }
+
+  function testGoogleAnalyticsConfiguration() {
+    // Check for setting page's presence.
+    $this->drupalGet('admin/config/system/googleanalytics');
+    $this->assertRaw(t('Web Property ID'), '[testGoogleAnalyticsConfiguration]: Settings page displayed.');
+
+    // Check for account code validation.
+    $edit['googleanalytics_account'] = $this->randomName(2);
+    $this->drupalPost('admin/config/system/googleanalytics', $edit, 'Save configuration');
+    $this->assertRaw(t('A valid Google Analytics Web Property ID is case sensitive and formatted like UA-xxxxxxx-yy.'), '[testGoogleAnalyticsConfiguration]: Invalid Web Property ID number validated.');
+  }
+
+  function testGoogleAnalyticsPageVisibility() {
+    $ua_code = 'UA-123456-1';
+    variable_set('googleanalytics_account', $ua_code);
+
+    // Show tracking on "every page except the listed pages".
+    variable_set('googleanalytics_visibility', 0);
+    // Disable tracking one "admin*" pages only.
+    variable_set('googleanalytics_pages', "admin\nadmin/*");
+    // Enable tracking only for authenticated users only.
+    variable_set('googleanalytics_roles', array(DRUPAL_AUTHENTICATED_RID => DRUPAL_AUTHENTICATED_RID));
+
+    // Check tracking code visibility.
+    $this->drupalGet('');
+    $this->assertRaw($ua_code, '[testGoogleAnalyticsPageVisibility]: Tracking code is displayed for authenticated users.');
+
+    // Test whether tracking code is not included on pages to omit.
+    $this->drupalGet('admin');
+    $this->assertNoRaw($ua_code, '[testGoogleAnalyticsPageVisibility]: Tracking code is not displayed on admin page.');
+    $this->drupalGet('admin/config/system/googleanalytics');
+    // Checking for tracking code URI here, as $ua_code is displayed in the form.
+    $this->assertNoRaw('google-analytics.com/ga.js', '[testGoogleAnalyticsPageVisibility]: Tracking code is not displayed on admin subpage.');
+
+    // Test whether tracking code display is properly flipped.
+    variable_set('googleanalytics_visibility', 1);
+    $this->drupalGet('admin');
+    $this->assertRaw($ua_code, '[testGoogleAnalyticsPageVisibility]: Tracking code is displayed on admin page.');
+    $this->drupalGet('admin/config/system/googleanalytics');
+    // Checking for tracking code URI here, as $ua_code is displayed in the form.
+    $this->assertRaw('google-analytics.com/ga.js', '[testGoogleAnalyticsPageVisibility]: Tracking code is displayed on admin subpage.');
+    $this->drupalGet('');
+    $this->assertNoRaw($ua_code, '[testGoogleAnalyticsPageVisibility]: Tracking code is NOT displayed on front page.');
+
+    // Test whether tracking code is not display for anonymous.
+    $this->drupalLogout();
+    $this->drupalGet('');
+    $this->assertNoRaw($ua_code, '[testGoogleAnalyticsPageVisibility]: Tracking code is NOT displayed for anonymous.');
+
+    // Switch back to every page except the listed pages.
+    variable_set('googleanalytics_visibility', 0);
+    // Enable tracking code for all user roles.
+    variable_set('googleanalytics_roles', array());
+
+    // Test whether 403 forbidden tracking code is shown if user has no access.
+    $this->drupalGet('admin');
+    $this->assertRaw('/403.html', '[testGoogleAnalyticsPageVisibility]: 403 Forbidden tracking code shown if user has no access.');
+
+    // Test whether 404 not found tracking code is shown on non-existent pages.
+    $this->drupalGet($this->randomName(64));
+    $this->assertRaw('/404.html', '[testGoogleAnalyticsPageVisibility]: 404 Not Found tracking code shown on non-existent page.');
+  }
+
+  function testGoogleAnalyticsTrackingCode() {
+    $ua_code = 'UA-123456-2';
+    variable_set('googleanalytics_account', $ua_code);
+
+    // Show tracking code on every page except the listed pages.
+    variable_set('googleanalytics_visibility', 0);
+    // Enable tracking code for all user roles.
+    variable_set('googleanalytics_roles', array());
+
+    /* Sample JS code as added to page:
+    <script type="text/javascript" src="/sites/all/modules/google_analytics/googleanalytics.js?w"></script>
+    <script type="text/javascript">
+      var _gaq = _gaq || [];
+      _gaq.push(['_setAccount', 'UA-123456-7']);
+      _gaq.push(['_trackPageview']);
+
+      (function() {
+        var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
+        ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
+        var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
+      })();
+    </script>
+    */
+
+    // Test whether tracking code uses latest JS.
+    variable_set('googleanalytics_cache', 0);
+    $this->drupalGet('');
+    $this->assertRaw('google-analytics.com/ga.js', '[testGoogleAnalyticsTrackingCode]: Latest tracking code used.');
+
+    // Test whether anonymize visitors IP address feature has been enabled.
+    $this->drupalGet('');
+    $this->assertNoRaw('_gaq.push(["_gat._anonymizeIp"]);', '[testGoogleAnalyticsTrackingCode]: Anonymize visitors IP address not found on frontpage.');
+    // Enable anonymizing of IP addresses.
+    variable_set('googleanalytics_tracker_anonymizeip', 1);
+    $this->drupalGet('');
+    $this->assertRaw('_gaq.push(["_gat._anonymizeIp"]);', '[testGoogleAnalyticsTrackingCode]: Anonymize visitors IP address found on frontpage.');
+
+    // Test whether single domain tracking is active.
+    $this->drupalGet('');
+    $this->assertNoRaw('_gaq.push(["_setDomainName"', '[testGoogleAnalyticsTrackingCode]: Single domain tracking is active.');
+
+    // Enable "One domain with multiple subdomains".
+    variable_set('googleanalytics_domain_mode', 1);
+    $this->drupalGet('');
+
+    // Test may run on localhost, an ipaddress or real domain name.
+    // TODO: Workaround to run tests successfully. This feature cannot tested reliable.
+    global $cookie_domain;
+    if (count(explode('.', $cookie_domain)) > 2 && !is_numeric(str_replace('.', '', $cookie_domain))) {
+      $this->assertRaw('_gaq.push(["_setDomainName",', '[testGoogleAnalyticsTrackingCode]: One domain with multiple subdomains is active on real host.');
+    }
+    else {
+      // Special cases, Localhost and IP addresses don't show '_setDomainName'.
+      $this->assertNoRaw('_gaq.push(["_setDomainName",', '[testGoogleAnalyticsTrackingCode]: One domain with multiple subdomains may be active on localhost (test result is not reliable).');
+    }
+
+    // Enable "Multiple top-level domains" tracking.
+    variable_set('googleanalytics_domain_mode', 2);
+    variable_set('googleanalytics_cross_domains', "www.example.com\nwww.example.net");
+    $this->drupalGet('');
+    $this->assertRaw('_gaq.push(["_setDomainName", "none"]);', '[testGoogleAnalyticsTrackingCode]: _setDomainName: "none" found. Cross domain tracking is active.');
+    $this->assertRaw('_gaq.push(["_setAllowLinker", true]);', '[testGoogleAnalyticsTrackingCode]: _setAllowLinker: true found. Cross domain tracking is active.');
+    $this->assertRaw('www.example.com|www.example.net', '[testGoogleAnalyticsTrackingCode]: Cross domain tracking with www.example.com and www.example.net is active.');
+
+    // Test whether the BEFORE and AFTER code is added to the tracker.
+    variable_set('googleanalytics_codesnippet_before', '_setDetectFlash(false);');
+    variable_set('googleanalytics_codesnippet_after', '_gaq.push(["t2._setAccount", "UA-123456-3"]);_gaq.push(["t2._trackPageview"]);');
+    $this->drupalGet('');
+    $this->assertRaw('_setDetectFlash(false);', '[testGoogleAnalyticsTrackingCode]: Before codesnippet has been found with "Flash" detection disabled.');
+    $this->assertRaw('t2._setAccount', '[testGoogleAnalyticsTrackingCode]: After codesnippet with "t2" tracker has been found.');
+  }
+
+}
+
+class GoogleAnalyticsRolesTest extends DrupalWebTestCase {
+
+  public static function getInfo() {
+    return array(
+      'name' => t('Google Analytics role tests'),
+      'description' => t('Test roles functionality of Google Analytics module.'),
+      'group' => 'Google Analytics',
+    );
+  }
+
+  function setUp() {
+    parent::setUp('googleanalytics');
+
+    $permissions = array(
+      'access administration pages',
+      'administer google analytics',
+    );
+
+    // User to set up google_analytics.
+    $this->admin_user = $this->drupalCreateUser($permissions);
+  }
+
+  function testGoogleAnalyticsRolesTracking() {
+    $ua_code = 'UA-123456-4';
+    variable_set('googleanalytics_account', $ua_code);
+
+    // Test if the default settings are working as expected.
+
+    // Add to the selected roles only.
+    variable_set('googleanalytics_visibility_roles', 0);
+    // Enable tracking for all users.
+    variable_set('googleanalytics_roles', array());
+
+    // Check tracking code visibility.
+    $this->drupalGet('');
+    $this->assertRaw($ua_code, '[testGoogleAnalyticsRoleVisibility]: Tracking code is displayed for anonymous users on frontpage with default settings.');
+    $this->drupalGet('admin');
+    $this->assertRaw('/403.html', '[testGoogleAnalyticsRoleVisibility]: 403 Forbidden tracking code is displayed for anonymous users in admin section with default settings.');
+
+    $this->drupalLogin($this->admin_user);
+
+    $this->drupalGet('');
+    $this->assertRaw($ua_code, '[testGoogleAnalyticsRoleVisibility]: Tracking code is displayed for authenticated users on frontpage with default settings.');
+    $this->drupalGet('admin');
+    $this->assertNoRaw($ua_code, '[testGoogleAnalyticsRoleVisibility]: Tracking code is NOT displayed for authenticated users in admin section with default settings.');
+
+    // Test if the non-default settings are working as expected.
+
+    // Enable tracking only for authenticated users.
+    variable_set('googleanalytics_roles', array(DRUPAL_AUTHENTICATED_RID => DRUPAL_AUTHENTICATED_RID));
+
+    $this->drupalGet('');
+    $this->assertRaw($ua_code, '[testGoogleAnalyticsRoleVisibility]: Tracking code is displayed for authenticated users only on frontpage.');
+
+    $this->drupalLogout();
+    $this->drupalGet('');
+    $this->assertNoRaw($ua_code, '[testGoogleAnalyticsRoleVisibility]: Tracking code is NOT displayed for anonymous users on frontpage.');
+
+    // Add to every role except the selected ones.
+    variable_set('googleanalytics_visibility_roles', 1);
+    // Enable tracking for all users.
+    variable_set('googleanalytics_roles', array());
+
+    // Check tracking code visibility.
+    $this->drupalGet('');
+    $this->assertRaw($ua_code, '[testGoogleAnalyticsRoleVisibility]: Tracking code is added to every role and displayed for anonymous users.');
+    $this->drupalGet('admin');
+    $this->assertRaw('/403.html', '[testGoogleAnalyticsRoleVisibility]: 403 Forbidden tracking code is shown for anonymous users if every role except the selected ones is selected.');
+
+    $this->drupalLogin($this->admin_user);
+
+    $this->drupalGet('');
+    $this->assertRaw($ua_code, '[testGoogleAnalyticsRoleVisibility]: Tracking code is added to every role and displayed on frontpage for authenticated users.');
+    $this->drupalGet('admin');
+    $this->assertNoRaw($ua_code, '[testGoogleAnalyticsRoleVisibility]: Tracking code is added to every role and NOT displayed in admin section for authenticated users.');
+
+    // Disable tracking for authenticated users.
+    variable_set('googleanalytics_roles', array(DRUPAL_AUTHENTICATED_RID => DRUPAL_AUTHENTICATED_RID));
+
+    $this->drupalGet('');
+    $this->assertNoRaw($ua_code, '[testGoogleAnalyticsRoleVisibility]: Tracking code is NOT displayed on frontpage for excluded authenticated users.');
+    $this->drupalGet('admin');
+    $this->assertNoRaw($ua_code, '[testGoogleAnalyticsRoleVisibility]: Tracking code is NOT displayed in admin section for excluded authenticated users.');
+
+    $this->drupalLogout();
+    $this->drupalGet('');
+    $this->assertRaw($ua_code, '[testGoogleAnalyticsRoleVisibility]: Tracking code is displayed on frontpage for included anonymous users.');
+  }
+
+}
diff --git a/sites/all/modules/google_analytics/googleanalytics.tokens.inc b/sites/all/modules/google_analytics/googleanalytics.tokens.inc
new file mode 100644
index 0000000000000000000000000000000000000000..2af09110d82683a8b33847e7cd3aef44bf6aadd7
--- /dev/null
+++ b/sites/all/modules/google_analytics/googleanalytics.tokens.inc
@@ -0,0 +1,56 @@
+<?php
+// $Id: googleanalytics.tokens.inc,v 1.1.2.4 2011/02/07 15:33:38 hass Exp $
+
+/**
+ * @file
+ * Builds placeholder replacement tokens for user-related data.
+ */
+
+/**
+ * Implements hook_token_info().
+ */
+function googleanalytics_token_info() {
+  $user['role-names'] = array(
+    'name' => t('User role names'),
+    'description' => t('The role names the user account is a member of as comma separated list.'),
+    'needs-data' => 'user',
+  );
+  $user['role-ids'] = array(
+    'name' => t('User role ids'),
+    'description' => t('The role ids the user account is a member of as comma separated list.'),
+    'needs-data' => 'user',
+  );
+
+  return array(
+    'tokens' => array('user' => $user),
+  );
+}
+
+/**
+ * Implements hook_tokens().
+ */
+function googleanalytics_tokens($type, $tokens, array $data = array(), array $options = array()) {
+  $sanitize = !empty($options['sanitize']);
+  $replacements = array();
+
+  if ($type == 'user' && !empty($data['user']->roles)) {
+    $account = $data['user'];
+
+    foreach ($tokens as $name => $original) {
+      switch ($name) {
+        // Basic user account information.
+        case 'role-names':
+          $names = implode(',', $account->roles);
+          $replacements[$original] = $sanitize ? check_plain($names) : $names;
+          break;
+
+        case 'role-ids':
+          $ids = implode(',', array_keys($account->roles));
+          $replacements[$original] = $sanitize ? check_plain($ids) : $ids;
+          break;
+      }
+    }
+  }
+
+  return $replacements;
+}