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

Side by Side 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: 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
(Empty)
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 /**
6 * Add your Analytics tracking ID here.
7 */
8 var _AnalyticsCode = 'UA-XXXXXX-X';
9
10 /**
11 * Below is a modified version of the Google Analytics asynchronous tracking
12 * code snippet. It has been modified to pull the HTTPS version of ga.js
13 * instead of the default HTTP version. It is recommended that you use this
14 * snippet instead of the standard tracking snippet provided when setting up
15 * a Google Analytics account.
16 */
17 var _gaq = _gaq || [];
18 _gaq.push(['_setAccount', _AnalyticsCode]);
19 _gaq.push(['_trackPageview']);
20
21 (function() {
22 var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.asy nc = true;
23 ga.src = 'https://ssl.google-analytics.com/ga.js';
24 var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore( ga, s);
25 })();
26
27 /**
28 * Track a click on a button using the asynchronous tracking API.
29 *
30 * See http://code.google.com/apis/analytics/docs/tracking/asyncTracking.html
31 * for information on how to use the asynchronous tracking API.
32 */
33 function trackButtonClick(e) {
34 _gaq.push(['_trackEvent', e.target.id, 'clicked']);
35 }
36
37 /**
38 * Now set up your event handlers for the popup's `button` elements once the
39 * popup's DOM has loaded.
40 */
41 document.addEventListener('DOMContentLoaded', function () {
42 var buttons = document.querySelectorAll('button');
43 for (var i = 0; i < buttons.length; i++) {
44 buttons[i].addEventListener('click', trackButtonClick);
45 }
46 });
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698