Search code examples
google-analyticsgoogle-analytics-apigoogle-analytics-firebase

Accessing Google analytics api using api key


I'm trying to implement Google analytics API using API key to make it available without authorization. But i can get examples using CLIENT ID in google developer console itself. Can anyone help me with an example using api key?


Solution

  • Google Analytics' EmbedAPI will allow you to display your Google Analytics via javascript, and users will be able to log in on page.

    You will still need to get your clientAPI, but then users will be able to login independently.

    The javascript code is described in the dev guide and a sample is below:

    <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,
        });
    </script>
    

    The API limit should be no problem, its 50,000 calls per day.