Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 0 additions & 3 deletions .hgignore

This file was deleted.

23 changes: 12 additions & 11 deletions GoogleAnalyticsPlugin.php → OmekaGoogleAnalyticsPlugin.php
Original file line number Diff line number Diff line change
Expand Up @@ -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'
);
Expand All @@ -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 = '<script type="text/javascript">'
. 'var accountId =' . js_escape($accountId) .';'
. $js
. '</script>';

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'];
Expand All @@ -71,6 +71,7 @@ public function hookConfig($args)
$post[GOOGLE_ANALYTICS_ACCOUNT_OPTION]
);
}

public function hookConfigForm()
{
include GOOGLE_ANALYTICS_PLUGIN_DIR . '/config_form.php';
Expand Down
13 changes: 7 additions & 6 deletions README.mkd → README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.

208 changes: 0 additions & 208 deletions build.xml

This file was deleted.

6 changes: 3 additions & 3 deletions config_form.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,10 @@
<p>To find you Google Analytics Account ID, follow these steps:</p>
<ol style="list-style: decimal inside;">
<li>Create or log into
<a href="https://www.google.com/analytics/" target="_blank">Google Analytics</a> account;
<a href="https://analytics.google.com/" target="_blank">Google Analytics</a> account;
</li>
<li> Add a &quot;Website Profile&quot; for this Omeka.net website;</li>
<li>Copy the value for the account ID found next to the site URL (starts with &quot;UA-&quot;);</li>
<li> Add a &quot;Property&quot; for this Omeka website;</li>
<li>Copy the value for the account ID found in Admin-&gt;Property-&gt;Tracking Info-&gt;Tracking Code. (starts with &quot;UA-&quot;);</li>
<li>Paste it into the text field above and save changes.</li>
</ol>

9 changes: 9 additions & 0 deletions gtag.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<!-- Global site tag (gtag.js) - Google Analytics -->
<script async src="https://www.googletagmanager.com/gtag/js?id=GA_MEASUREMENT_ID"></script>
<script>
window.dataLayer = window.dataLayer || [];
function gtag(){dataLayer.push(arguments);}
gtag('js', new Date());

gtag('config', 'GA_MEASUREMENT_ID');
</script>
5 changes: 2 additions & 3 deletions plugin.ini
Original file line number Diff line number Diff line change
@@ -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=""

9 changes: 0 additions & 9 deletions snippet.js

This file was deleted.