Forum Post: RE: Integration with Social Media API

  • Thread starter Thread starter Godfrey Sorita
  • Start date Start date
Status
Not open for further replies.
G

Godfrey Sorita

Guest
You can also use Google Analytics Embed API to display dashboards in Rollbase pages. For more information on this API, please check their documentation: https://developers.google.com/analytics/devguides/reporting/embed/v1/ So far the charts have worked in my page but it will require a user to login with their Google Account. Please paste the script below in a script component and update the value of CLIENT_ID: !-- Step 1: Create the containing elements. -- section id="auth-button" /section section id="view-selector" /section section id="timeline" /section !-- Step 2: Load the library. -- script (function(w,d,s,g,js,fjs){ g=w.gapi||(w.gapi={});g.analytics={q:[],ready:function(cb){this.q.push(cb)}}; js=d.createElement(s);fjs=d.getElementsByTagName(s)[0]; js.src='https://apis.google.com/js/platform.js'; fjs.parentNode.insertBefore(js,fjs);js.onload=function(){g.load('analytics')}; }(window,document,'script')); /script script gapi.analytics.ready(function() { // Step 3: Authorize the user. var CLIENT_ID = 'Insert your client ID here'; gapi.analytics.auth.authorize({ container: 'auth-button', clientid: CLIENT_ID, }); // Step 4: Create the view selector. var viewSelector = new gapi.analytics.ViewSelector({ container: 'view-selector' }); // Step 5: Create the timeline chart. var timeline = new gapi.analytics.googleCharts.DataChart({ reportType: 'ga', query: { 'dimensions': 'ga:date', 'metrics': 'ga:sessions', 'start-date': '30daysAgo', 'end-date': 'yesterday', }, chart: { type: 'LINE', container: 'timeline' } }); // Step 6: Hook up the components to work together. gapi.analytics.auth.on('success', function(response) { viewSelector.execute(); }); viewSelector.on('change', function(ids) { var newIds = { query: { ids: ids } } timeline.set(newIds).execute(); }); }); /script

Continue reading...
 
Status
Not open for further replies.
Back
Top