Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(8181)

Unified Diff: chrome/common/extensions/docs/examples/tutorials/analytics/popup.js

Issue 9212044: Improving `content_security_policy` documentation. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Meggin's feedback. Created 8 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: chrome/common/extensions/docs/examples/tutorials/analytics/popup.js
diff --git a/chrome/common/extensions/docs/examples/tutorials/analytics/popup.js b/chrome/common/extensions/docs/examples/tutorials/analytics/popup.js
new file mode 100644
index 0000000000000000000000000000000000000000..160fe15178b5cba1fa32e1bf2f138b12b3e3d6c4
--- /dev/null
+++ b/chrome/common/extensions/docs/examples/tutorials/analytics/popup.js
@@ -0,0 +1,49 @@
+// Copyright (c) 2012 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+/**
+ * Add your Analytics tracking ID here.
+ */
+var _AnalyticsCode = 'UA-XXXXXX-X';
+
+/**
+ * Below is a modified version of the Google Analytics asynchronous tracking
+ * code snippet. It has been modified to pull the HTTPS version of ga.js
+ * instead of the default HTTP version. It is recommended that you use this
+ * snippet instead of the standard tracking snippet provided when setting up
+ * a Google Analytics account.
+ */
+var _gaq = _gaq || [];
+_gaq.push(['_setAccount', _AnalyticsCode]);
+_gaq.push(['_trackPageview']);
+
+(function() {
+ var ga = document.createElement('script');
+ ga.type = 'text/javascript';
+ ga.async = true;
+ ga.src = 'https://ssl.google-analytics.com/ga.js';
+ var s = document.getElementsByTagName('script')[0];
+ s.parentNode.insertBefore(ga, s);
+})();
+
+/**
+ * Track a click on a button using the asynchronous tracking API.
+ *
+ * See http://code.google.com/apis/analytics/docs/tracking/asyncTracking.html
+ * for information on how to use the asynchronous tracking API.
+ */
+function trackButtonClick(e) {
+ _gaq.push(['_trackEvent', e.target.id, 'clicked']);
+}
+
+/**
+ * Now set up your event handlers for the popup's `button` elements once the
+ * popup's DOM has loaded.
+ */
+document.addEventListener('DOMContentLoaded', function () {
+ var buttons = document.querySelectorAll('button');
+ for (var i = 0; i < buttons.length; i++) {
+ buttons[i].addEventListener('click', trackButtonClick);
+ }
+});
« no previous file with comments | « chrome/common/extensions/docs/examples/tutorials/analytics/popup.html ('k') | chrome/common/extensions/docs/manifest.html » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698