How can I restrict analytics embed api to display only one google analytics account. Right now I have three accounts showing up under dropdown.
A given web property should only be tracked in one Analytics account. Tracking a single web property in different Analytics accounts is not currently recommended. You do not need to sign in separately for each Analytics account that you have access to.
As Philip Walton said, the viewselector will always show all accounts etc. And to have only one 'view' you will not need the selector and add the id to the chart data
As example, in case you would use the https://developers.google.com/analytics/devguides/reporting/embed/v1/devguide demo as a starting point. To have it show only one view, replace step 3 to 6 by:
<script>
gapi.analytics.ready(function() {
// Step 3: Authorize the user.
var CLIENT_ID = 'insert client id here';
gapi.analytics.auth.authorize({
container: 'auth-button',
clientid: CLIENT_ID,
});
// Step 4: Create the timeline chart.
var timeline = new gapi.analytics.googleCharts.DataChart({
reportType: 'ga',
query: {
'ids': 'ga:insert view id here',
'dimensions': 'ga:date',
'metrics': 'ga:sessions',
'start-date': '30daysAgo',
'end-date': 'yesterday',
},
chart: {
type: 'LINE',
container: 'timeline'
}
});
timeline.execute();
});
</script>
So you can delete step 4 and 6 of the original one and edit step 5 by adding ids: YOURVIEWID to var timeline. Afterwards add timeline.execute() to render the chart
The ids needed can be found by using https://ga-dev-tools.appspot.com/account-explorer/ and the needed id is displayed at the button under 'view'
The Embed API's ViewSelector
component is always going to show you a list of all your accounts, properties, and views.
If you know exactly what view you want to display data for, then you don't need to use the ViewSelector
component at all, you just need to pass the view ID (ids
) directly to the Report
or DataChart
components.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With