PageRenderTime 50ms CodeModel.GetById 26ms RepoModel.GetById 1ms app.codeStats 0ms

/src/GA.NET.Core/RemySharp/noscript.php

https://github.com/erikzaadi/GA.NET
PHP | 92 lines | 56 code | 12 blank | 24 comment | 2 complexity | 2720a43b25b5f87cbe8dd10a2ba03c1c MD5 | raw file
  1. <?php
  2. /*
  3. Plugin Name: No Script Google Analytics
  4. Plugin URI: http://remysharp.com
  5. Description: Includes a Google analytics tracker for users without JavaScript enabled
  6. Version: 0.1
  7. Author: Remy Sharp
  8. Author URI: http://remysharp.com
  9. Copyright 2009 Remy Sharp (email : remy at remysharp dot com)
  10. This program is free software; you can redistribute it and/or modify
  11. it under the terms of the GNU General Public License as published by
  12. the Free Software Foundation; either version 2 of the License, or
  13. (at your option) any later version.
  14. This program is distributed in the hope that it will be useful,
  15. but WITHOUT ANY WARRANTY; without even the implied warranty of
  16. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  17. GNU General Public License for more details.
  18. You should have received a copy of the GNU General Public License
  19. along with this program; if not, write to the Free Software
  20. Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
  21. */
  22. function google_noscript_panel() {
  23. if (isset($_POST['save_no_script_settings'])) {
  24. $option_noscript_google_ua = $_POST['noscript_google_ua'];
  25. update_option('noscript_google_ua', $option_noscript_google_ua);
  26. ?>
  27. <div class="updated">
  28. <p>No Script analytics settings saved</p>
  29. </div>
  30. <?php
  31. }
  32. ?>
  33. <div class="wrap">
  34. <h2>Google No Script Google Analytic Settings</h2>
  35. <form method="post">
  36. <table class="form-table">
  37. <tr valign="top">
  38. <th scope="row">Analytics Account ID</th>
  39. <td>
  40. <input name="noscript_google_ua" type="text" id="flickr_id" value=""<?php echo get_option('noscript_google_ua'); ?>" size="20" />
  41. </td>
  42. </tr>
  43. </table>
  44. <div class="submit">
  45. <input type="submit" name="save_no_script_settings" value=""<?php _e('Save Settings', 'save_no_script_settings') ?>" />
  46. </div>
  47. </form>
  48. </div>
  49. <?php
  50. }
  51. function google_noscript() {
  52. $var_utmac = get_option('noscript_google_ua');
  53. $var_utmhn = get_bloginfo('url'); //enter your domain
  54. $var_utmn = rand(1000000000,9999999999); //random request number
  55. $var_cookie = rand(10000000,99999999); //random cookie number
  56. $var_random = rand(1000000000,2147483647); //number under 2147483647
  57. $var_today = time(); //today
  58. $var_referer = @$_SERVER['HTTP_REFERER']; //referer url
  59. $var_uservar = '-'; //enter your own user defined variable
  60. $var_utmp = '/noscript'; //this example adds a fake file request to the (fake) tracker directory (the image/pdf filename).
  61. $urchinUrl = 'http://www.google-analytics.com/__utm.gif?utmwv=1&utmn='.$var_utmn.'&utmsr=-&utmsc=-&utmul=-&utmje=0&utmfl=-&utmdt=-&utmhn='.$var_utmhn.'&utmr='.$var_referer.'&utmp='.$var_utmp.'&utmac='.$var_utmac.'&utmcc=__utma%3D'.$var_cookie.'.'.$var_random.'.'.$var_today.'.'.$var_today.'.'.$var_today.'.2%3B%2B__utmb%3D'.$var_cookie.'%3B%2B__utmc%3D'.$var_cookie.'%3B%2B__utmz%3D'.$var_cookie.'.'.$var_today.'.2.2.utmccn%3D(direct)%7Cutmcsr%3D(direct)%7Cutmcmd%3D(none)%3B%2B__utmv%3D'.$var_cookie.'.'.$var_uservar.'%3B';
  62. ?>
  63. <!-- Google analytics JS disabled plugin -->
  64. <noscript>
  65. <img src=""<?php echo $urchinUrl ?>" style="display: none;" />
  66. </noscript>
  67. <?php
  68. }
  69. function google_noscript_admin_menu() {
  70. if (function_exists('add_options_page')) {
  71. add_options_page('No Script Analytics', 'No Script Analytics', 8, basename(__FILE__), 'google_noscript_panel');
  72. }
  73. }
  74. add_action('admin_menu', 'google_noscript_admin_menu');
  75. add_action('wp_footer', 'google_noscript');
  76. ?>