diff --git a/.hgignore b/.hgignore deleted file mode 100644 index 7ead5da..0000000 --- a/.hgignore +++ /dev/null @@ -1,3 +0,0 @@ -\.sw.*$ -~$ -build/ diff --git a/GoogleAnalyticsPlugin.php b/OmekaGoogleAnalyticsPlugin.php similarity index 80% rename from GoogleAnalyticsPlugin.php rename to OmekaGoogleAnalyticsPlugin.php index fe90240..a1b4ccd 100644 --- a/GoogleAnalyticsPlugin.php +++ b/OmekaGoogleAnalyticsPlugin.php @@ -23,16 +23,16 @@ * */ -define('GOOGLE_ANALYTICS_PLUGIN_VERSION', get_plugin_ini('GoogleAnalytics', 'version')); +define('GOOGLE_ANALYTICS_PLUGIN_VERSION', get_plugin_ini('OmekaGoogleAnalytics', 'version')); define('GOOGLE_ANALYTICS_PLUGIN_DIR', dirname(__FILE__)); define('GOOGLE_ANALYTICS_ACCOUNT_OPTION', 'googleanalytics_account_id'); -class GoogleAnalyticsPlugin extends Omeka_Plugin_AbstractPlugin +class OmekaGoogleAnalyticsPlugin extends Omeka_Plugin_AbstractPlugin { protected $_hooks =array( 'install', 'uninstall', - 'public_footer', + 'public_head', 'config', 'config_form' ); @@ -43,26 +43,26 @@ public function hookInstall() { set_option('googleanalytics_version', GOOGLE_ANALYTICS_PLUGIN_DIR); } + public function hookUninstall() { delete_option('googleanalytics_version'); delete_option(GOOGLE_ANALYTICS_ACCOUNT_OPTION); } - public function hookPublicFooter() + + public function hookPublicHead() { $accountId = get_option(GOOGLE_ANALYTICS_ACCOUNT_OPTION); if (empty($accountId)) { return; } - $js = file_get_contents(GOOGLE_ANALYTICS_PLUGIN_DIR . '/snippet.js'); - $html = ''; - - echo $html; + $jstemplate = file_get_contents(GOOGLE_ANALYTICS_PLUGIN_DIR . '/gtag.js'); + $js = str_replace("GA_MEASUREMENT_ID", $accountId, $jstemplate); + + echo $js; } + public function hookConfig($args) { $post = $args['post']; @@ -71,6 +71,7 @@ public function hookConfig($args) $post[GOOGLE_ANALYTICS_ACCOUNT_OPTION] ); } + public function hookConfigForm() { include GOOGLE_ANALYTICS_PLUGIN_DIR . '/config_form.php'; diff --git a/README.mkd b/README.md similarity index 64% rename from README.mkd rename to README.md index e1faf81..27ed1d4 100644 --- a/README.mkd +++ b/README.md @@ -13,16 +13,17 @@ Plugins](http://omeka.org/codex/Managing_Plugins) for more information). On the configuration screen, you will need to paste in the Google Analytics JavaScript. You can do that by following these steps: - 1. Log onto [Google Analytics](https://www.google.com/analytics/); + 1. Log onto [Google Analytics](https://analytics.google.com/) - 2. Click "Edit" for the profile you wish to use; + 2. Click "Admin" in the bottom left - 3. Click "Check Status" (it will be a small link near the top of the page); + 3. Select the Account and Property you wish to add Google Analytics to - 4. Copy all of the text in the box labelled "Paste this code on your site"; - and + 4. Click "Tracking Info" then "Tracking Code" + + 5. Copy the Tracking ID at the top of the page (starts with 'UA-') - 5. Paste it into the box on the plugin configuration page. + 5. Paste it into the box on the plugin configuration page and save changes That's it. You should start seeing results in Google Analytics in 24-48 hours. diff --git a/build.xml b/build.xml deleted file mode 100644 index 05d00dc..0000000 --- a/build.xml +++ /dev/null @@ -1,208 +0,0 @@ - - - - - - - A simple build file for Omeka plugins. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/config_form.php b/config_form.php index c2af29d..96537c8 100644 --- a/config_form.php +++ b/config_form.php @@ -19,10 +19,10 @@

To find you Google Analytics Account ID, follow these steps:

  1. Create or log into -Google Analytics account; +Google Analytics account;
  2. -
  3. Add a "Website Profile" for this Omeka.net website;
  4. -
  5. Copy the value for the account ID found next to the site URL (starts with "UA-");
  6. +
  7. Add a "Property" for this Omeka website;
  8. +
  9. Copy the value for the account ID found in Admin->Property->Tracking Info->Tracking Code. (starts with "UA-");
  10. Paste it into the text field above and save changes.
diff --git a/gtag.js b/gtag.js new file mode 100644 index 0000000..465cf6b --- /dev/null +++ b/gtag.js @@ -0,0 +1,9 @@ + + + diff --git a/plugin.ini b/plugin.ini index 1c7b701..a755f29 100644 --- a/plugin.ini +++ b/plugin.ini @@ -1,12 +1,11 @@ [info] - name="GoogleAnalytics" + name="OmekaGoogleAnalytics" author="Scholars' Lab" description="A small plugin to include Google Analytics JavaScript code on pages." - link="https://github.com/erochest/GoogleAnalyticsErr/wiki" + link="https://github.com/DigitalCarleton/OmekaGoogleAnalytics" version="1.3-2.0" tags="google, analytics" omeka_minimum_version="2.1" - omeka_tested_up_to="2.1.4" optional_plugins="" required_plugins="" diff --git a/snippet.js b/snippet.js deleted file mode 100644 index d0e86bf..0000000 --- a/snippet.js +++ /dev/null @@ -1,9 +0,0 @@ -var _gaq = _gaq || []; -_gaq.push(['_setAccount', accountId]); -_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); -})();