how to display stats from two different sites on the one page

46 views
Skip to first unread message

tim worley

unread,
Jun 23, 2013, 7:48:15 PM6/23/13
to ga-easy-da...@googlegroups.com
Hi,

I have a number of cases where clients have more than one site.  Of course, we want to show stats from both sites, on the one page.

How do we achieve this please?

Curtis David

unread,
May 29, 2014, 4:26:11 PM5/29/14
to ga-easy-da...@googlegroups.com
I did it by adding another div and chart var for each profile (at each other site).

I wanted to add more than 10 sites .. but there is a rate limit for API calls (for free API access) that is 10 per user per second.  So if you want to do more than 10 sites you have to do some rate limiting otherwise the API will only return 10 calls.  I looked into this but didn't get anything working for  me so just went with 10 sites for now.

I thought about creating some variables for profile and title elements, and then doing a loop rather than just copy paste div and chart var code but it was easy to copy paste and edit 10 times.

Example is below.

Cheers!

      <!-- Div element where the first profile/site Chart will be placed -->
  <div id='line-chart-example-1'></div>   

      <!-- Div element where the second profile/site Chart will be placed -->
  <div id='line-chart-example-2'></div>   


  // Create a Chart var for first profile/site
    // visualizes in a line chart.
    var chart1 = new gadash.Chart({
      'type': 'LineChart',
      'divContainer': 'line-chart-example-1',
      'last-n-days':30,
      'query': {
        'ids': 'ga:xxxxxxxx', <= profile id for first site
        'metrics': 'ga:visitors,ga:pageviews,ga:visits,ga:pageviews',
        'dimensions': 'ga:date'
      },
      'chartOptions': {
        width: 800,
        height: 110,
        title: 'site 1 last 30 days',
        hAxis: {title:'Date'},
        vAxis: {title:''},
        orientation: 'horizontal',
        bar: {groupWidth: "95%"}
        //curveType: 'function'
      }
    }).render();

  // Create a Chart var for second profile/site
    // visualizes in a line chart.
    var chart1 = new gadash.Chart({
      'type': 'LineChart',
      'divContainer': 'line-chart-example-2',
      'last-n-days':30,
      'query': {
        'ids': 'ga:xxxxxxxx', <= profile id for second site
        'metrics': 'ga:visitors,ga:pageviews,ga:visits,ga:pageviews',
        'dimensions': 'ga:date'
      },
      'chartOptions': {
        width: 800,
        height: 110,
        title: 'site 2 last 30 days',
        hAxis: {title:'Date'},
        vAxis: {title:''},
        orientation: 'horizontal',
        bar: {groupWidth: "95%"}
        //curveType: 'function'
      }
    }).render();
Reply all
Reply to author
Forward
0 new messages