{"id":51870,"date":"2016-11-02T12:36:56","date_gmt":"2016-11-02T12:36:56","guid":{"rendered":"https:\/\/wordpress.org\/plugins-wp\/multi-google-analytics\/"},"modified":"2017-09-11T09:34:51","modified_gmt":"2017-09-11T09:34:51","slug":"multi-google-analytics","status":"publish","type":"plugin","link":"https:\/\/sr.wordpress.org\/plugins\/multi-google-analytics\/","author":7735589,"comment_status":"closed","ping_status":"closed","template":"","meta":{"_crdt_document":"","version":"1.1.2","stable_tag":"1.1.2","tested":"4.8.28","requires":"4.0","requires_php":"","requires_plugins":"","header_name":"Multiple Google Analytics Trackers","header_author":"Jens Ahrengot Boddum","header_description":"","assets_banners_color":"b1b8c1","last_updated":"2017-09-11 09:34:51","external_support_url":"","external_repository_url":"","donate_link":"","header_plugin_uri":"https:\/\/github.com\/Ahrengot\/multiple-google-analytics","header_author_uri":"http:\/\/ahrengot.com\/","rating":3.7,"author_block_rating":0,"active_installs":70,"downloads":4472,"num_ratings":3,"support_threads":0,"support_threads_resolved":0,"author_block_count":0,"sections":["description","installation","faq","changelog"],"tags":[],"upgrade_notice":{"1.1.2":"<p>Add support for the new longer google analytics ID\u2019s<\/p>","1.1.1":"<p>Fixes a bug where default values weren\u2019t set properly when first activating plugin<\/p>","1.0.1":"<p>Fixes typos in plugin activation\/deactivation callback functions<\/p>","1.0.0":"<p>Initial plugin release.<\/p>"},"ratings":{"1":"1","2":0,"3":0,"4":0,"5":"2"},"assets_icons":{"icon-256x256.png":{"filename":"icon-256x256.png","revision":"1526714","resolution":"256x256","location":"assets"}},"assets_banners":{"banner-1544x500.jpg":{"filename":"banner-1544x500.jpg","revision":"1526718","resolution":"1544x500","location":"assets"},"banner-1880x609.jpg":{"filename":"banner-1880x609.jpg","revision":"1526714","resolution":"1880x609","location":"assets"},"banner-720x250.jpg":{"filename":"banner-720x250.jpg","revision":"1526718","resolution":"720x250","location":"assets"}},"assets_blueprints":{},"all_blocks":[],"tagged_versions":["1.0.0","1.0.1","1.1.1","1.1.2"],"block_files":[],"assets_screenshots":{"screenshot-1.png":{"filename":"screenshot-1.png","revision":"1526665","resolution":"1","location":"assets"},"screenshot-2.png":{"filename":"screenshot-2.png","revision":"1526665","resolution":"2","location":"assets"}},"screenshots":{"1":"Default settings with 1 tracker and the script printed in wp_footer()","2":"Using multiple trackers and the custom hook for printing the script"},"jetpack_post_was_ever_published":false},"plugin_section":[],"plugin_tags":[232,150,1005,521,522],"plugin_category":[36],"plugin_contributors":[125810],"plugin_business_model":[],"class_list":["post-51870","plugin","type-plugin","status-publish","hentry","plugin_tags-analytics","plugin_tags-google","plugin_tags-google-analytics","plugin_tags-statistics","plugin_tags-stats","plugin_category-analytics","plugin_contributors-ahrengot","plugin_committers-ahrengot"],"banners":[],"icons":{"svg":false,"icon":"https:\/\/ps.w.org\/multi-google-analytics\/assets\/icon-256x256.png?rev=1526714","icon_2x":"https:\/\/ps.w.org\/multi-google-analytics\/assets\/icon-256x256.png?rev=1526714","generated":false},"screenshots":[{"src":"https:\/\/ps.w.org\/multi-google-analytics\/assets\/screenshot-1.png?rev=1526665","caption":"Default settings with 1 tracker and the script printed in wp_footer()"},{"src":"https:\/\/ps.w.org\/multi-google-analytics\/assets\/screenshot-2.png?rev=1526665","caption":"Using multiple trackers and the custom hook for printing the script"}],"raw_content":"<!--section=description-->\n<p>Minimalistic <a href=\"http:\/\/www.google.com\/analytics\/\">Google Analytics<\/a> plugin that lets you add one or more trackers and control exactly how the script is rendered.<\/p>\n\n<h4>Rendering the script<\/h4>\n\n<p>This plugin lets you control wether the Google Analytics script is printed in the <code>&lt;head&gt;<\/code>-element, the <code>&lt;body&gt;<\/code>-element or using a custom action.<\/p>\n\n<p>There's also a filter available, if you want to completely override the code that prints the analytics code. This way you can use the plugin simply for storing the property ID's in the database and manually render the analytics script exactly as your want it.<\/p>\n\n<p>The filter for overriding the script code is <code>ahr-google-analtyics\/script_file_path<\/code> and you'd use it like so:<\/p>\n\n<pre><code>add_filter('ahr-google-analtyics\/script_file_path', function($default_path){\n    \/\/ return an absolute file path to the file you want to use for rendering the script\n}, 10, 1);\n<\/code><\/pre>\n\n<h4>Accessing the property ids via code<\/h4>\n\n<p>If you need to manipulate the Google Analytics property ids before they are printed, then use the <code>ahr-google-analtyics'\/property_ids<\/code> filter. It'll pass you an array of property ids as its single argument.<\/p>\n\n<p>If you need to pull the ids from the database, in any other context, you can use <code>$property_ids = get_option( AhrGoogleAnalytics::OPTION_IDS );<\/code><\/p>\n\n<p>This plugin will always give you an array of ids. Even if you just have one.<\/p>\n\n<h4>Source code &amp; contributions<\/h4>\n\n<p>Please feel free to contribute improvements, report bugs or suggest new features via the GitHub repo<\/p>\n\n<ul>\n<li><a href=\"https:\/\/github.com\/Ahrengot\/multiple-google-analytics\">Github Repo<\/a><\/li>\n<li><a href=\"https:\/\/github.com\/Ahrengot\/multiple-google-analytics\/issues\">Suggest improvements<\/a><\/li>\n<li><a href=\"https:\/\/github.com\/Ahrengot\/multiple-google-analytics\/pulls\">Open a pull request<\/a><\/li>\n<\/ul>\n\n<!--section=installation-->\n<ol>\n<li>Move the <code>ahr-google-analytics<\/code> folder to the <code>\/wp-content\/plugins\/<\/code> directory OR search for \u2018Multiple Google Analytics' and add the plugin using WordPress' plugin browser.<\/li>\n<li>Activate the plugin through the 'Plugins' page in WordPress<\/li>\n<li>Add one or more web property IDs (UA-XXXXXXX-X strings) on the settings page<\/li>\n<\/ol>\n\n<!--section=faq-->\n<dl>\n<dt>Installation Instructions<\/dt>\n<dd><ol>\n<li>Move the <code>ahr-google-analytics<\/code> folder to the <code>\/wp-content\/plugins\/<\/code> directory OR search for \u2018Multiple Google Analytics' and add the plugin using WordPress' plugin browser.<\/li>\n<li>Activate the plugin through the 'Plugins' page in WordPress<\/li>\n<li>Add one or more web property IDs (UA-XXXXXXX-X strings) on the settings page<\/li>\n<\/ol><\/dd>\n<dt>What is a Google Analytics property ID?<\/dt>\n<dd><p>It's the string looking like <code>UA-XXXXXXX-X<\/code> next to your website URL on https:\/\/analytics.google.com\/analytics\/web\/<\/p><\/dd>\n<dt>JavaScript: How do I track pageviews\/events\/etc. using multiple trackers<\/dt>\n<dd><p>If you're building a JavaScript-based web app and manually need to track custom routes or events you can use the <code>ga.getAll()<\/code> method to get an array of registered trackers and then run the tracking logic for each tracker.<\/p>\n\n<p>For example, this will track page views based on custom routes:<\/p>\n\n<pre><code>if ( typeof ga === 'function' &amp;&amp; typeof ga.getAll === 'function' ) {\n  ga.getAll().forEach(tracker =&gt; {\n    tracker.set('page', *my-custom-route*); \/\/ Custom route e.g. '\/my-page'\n    tracker.send('pageview');\n  })\n}\n<\/code><\/pre>\n\n<p>And here's an example of tracking custom events:<\/p>\n\n<pre><code>if ( typeof ga === 'function' &amp;&amp; typeof ga.getAll === 'function' ) {\n  ga.getAll().forEach(tracker =&gt; {\n    tracker.send('event', {\n      eventCategory: 'Search',\n      eventAction: 'Query',\n      eventLabel: *query*, \/\/ Your search query\n      eventValue: *matches.length* \/\/ Optionally, send the number of matches for the query\n    });\n  })\n}\n<\/code><\/pre><\/dd>\n\n<\/dl>\n\n<!--section=changelog-->\n<h4>1.1.2<\/h4>\n\n<p>Release Date: September 11th, 2017<\/p>\n\n<p>Add support for the new longer google analytics ID\u2019s that would previously be rejected by the validator<\/p>\n\n<h4>1.1.1<\/h4>\n\n<p>Release Date: March 15th, 2017<\/p>\n\n<p>Fixes a bug where default values weren\u2019t set properly when first activating plugin<\/p>\n\n<h4>1.0.1<\/h4>\n\n<p>Release Date: December 11th, 2016<\/p>\n\n<p>Fixes typos in plugin activation\/deactivation callback functions<\/p>\n\n<h4>1.0.0<\/h4>\n\n<p>Release Date: November 2nd, 2016<\/p>\n\n<ul>\n<li>Initial release. Yay!<\/li>\n<\/ul>","raw_excerpt":"Add one or more Google Analytics trackers to your website.","jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/sr.wordpress.org\/plugins\/wp-json\/wp\/v2\/plugin\/51870","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/sr.wordpress.org\/plugins\/wp-json\/wp\/v2\/plugin"}],"about":[{"href":"https:\/\/sr.wordpress.org\/plugins\/wp-json\/wp\/v2\/types\/plugin"}],"replies":[{"embeddable":true,"href":"https:\/\/sr.wordpress.org\/plugins\/wp-json\/wp\/v2\/comments?post=51870"}],"author":[{"embeddable":true,"href":"https:\/\/sr.wordpress.org\/plugins\/wp-json\/wporg\/v1\/users\/ahrengot"}],"wp:attachment":[{"href":"https:\/\/sr.wordpress.org\/plugins\/wp-json\/wp\/v2\/media?parent=51870"}],"wp:term":[{"taxonomy":"plugin_section","embeddable":true,"href":"https:\/\/sr.wordpress.org\/plugins\/wp-json\/wp\/v2\/plugin_section?post=51870"},{"taxonomy":"plugin_tags","embeddable":true,"href":"https:\/\/sr.wordpress.org\/plugins\/wp-json\/wp\/v2\/plugin_tags?post=51870"},{"taxonomy":"plugin_category","embeddable":true,"href":"https:\/\/sr.wordpress.org\/plugins\/wp-json\/wp\/v2\/plugin_category?post=51870"},{"taxonomy":"plugin_contributors","embeddable":true,"href":"https:\/\/sr.wordpress.org\/plugins\/wp-json\/wp\/v2\/plugin_contributors?post=51870"},{"taxonomy":"plugin_business_model","embeddable":true,"href":"https:\/\/sr.wordpress.org\/plugins\/wp-json\/wp\/v2\/plugin_business_model?post=51870"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}