| OLD | NEW |
| (Empty) | |
| 1 <!DOCTYPE html> |
| 2 <html> |
| 3 <head> |
| 4 <meta charset="utf-8"> |
| 5 <title>Google Analytics JavaScript API Untilities Demo</title> |
| 6 </head> |
| 7 <body> |
| 8 |
| 9 <div id="embed-api-auth-container"></div> |
| 10 <pre id="account-summaries-output"></pre> |
| 11 |
| 12 <!-- Load the account summaries module, it will be at: |
| 13 `window.gaApiUtils.accountSummaries` --> |
| 14 <script src="ga-api-utils.js"></script> |
| 15 |
| 16 <script> |
| 17 // Use the Embed API to authorize the user. |
| 18 (function(w,d,s,g,js,fs){ |
| 19 g=w.gapi||(w.gapi={});g.analytics={q:[],ready:function(f){this.q.push(f);}}; |
| 20 js=d.createElement(s);fs=d.getElementsByTagName(s)[0]; |
| 21 js.src='https://apis.google.com/js/platform.js'; |
| 22 fs.parentNode.insertBefore(js,fs);js.onload=function(){g.load('analytics');}; |
| 23 }(window,document,'script')); |
| 24 |
| 25 gapi.analytics.ready(function() { |
| 26 |
| 27 // Run the demo once the user is authorized. |
| 28 gapi.analytics.auth.on('success', gaApiUtilsDemo); |
| 29 |
| 30 // This client ID will work at http://localhost:8080. |
| 31 // To run this demo on other hosts or ports, you must use your own client ID. |
| 32 gapi.analytics.auth.authorize({ |
| 33 container: 'embed-api-auth-container', |
| 34 clientid: '793177639245-olst43lspv93vkoql0b9l26hmpf9kfmv.apps.googleusercont
ent.com', |
| 35 }); |
| 36 }); |
| 37 |
| 38 function gaApiUtilsDemo() { |
| 39 var output = document.getElementById('account-summaries-output'); |
| 40 gaApiUtils.accountSummaries.get().then( |
| 41 function onResolved(summaries) { |
| 42 output.innerText = JSON.stringify(summaries.all(), null, 2); |
| 43 }, |
| 44 function onRejected(error) { |
| 45 output.innerText = error.message; |
| 46 } |
| 47 ); |
| 48 } |
| 49 </script> |
| 50 |
| 51 </body> |
| 52 </html> |
| OLD | NEW |