4

I am using the Google Analytics Javascript library to let users view a GeoMap of the particular page they are on. However, everytime they attempt to do so, thye have to go through an authentication process only to have my data displayed on my page. How can I find an alternative to this. I only want to embed my Analytics data through a visualized graph on my page so that all anonymous viewers can see it


**We have created an account in Google analytics. Now we are able to get the statistics of the site. Open the site http://Example.com Click on Authorize Analytics button. Provide the credentials of the Google account in the opened window. Username: [email protected] Password: xxx It will redirect to http://Example.com page. Enter the table id ga:61737784 and click on Draw Charts Button, then u will get the statistics for the site.

My requirement is without login in to Google analytics site I should get the statistics. Because the end user don’t know the credentials of Google analytics. The below is the html and javascript code.**

 <script src="http://apis.google.com/js/client.js?onload=gadashInit" type="text/javascript"></script>
 <script src="http://analytics-api-samples.googlecode.com/svn/trunk/src/reporting/javascript/ez-ga-dash/gadash-1.0.js" type="text/javascript"></script>
 <script src="http://www.google.com/jsapi" type="text/javascript"></script>
 <script src="http://www.google-analytics.com/ga.js" type="text/javascript"></script>
 <script type="text/javascript">
 gadash.configKeys({
 'apiKey': xxxxx',
 'clientId':xxxxx'
 }); 
 var dataOverTime = new gadash.Chart();
 var scoreCard = new gadash.Chart();
 var sourceMediumTable = new gadash.Chart(); 
 var baseConfig = {
 'last-n-days': 30,
 'query': {
 'metrics': 'ga:visitors, ga:visits, ga:pageviews',
 },
 'chartOptions': {
 width: 400
 }
 }; 
 var dataOverTimeConfig = {
 'divContainer': 'dataOverTimeConfig',
 'type': 'LineChart',
 'query': {
 'dimensions': 'ga:date',
 'sort': 'ga:date'
 },
 'chartOptions': {
 height: 250,
 legend: {position: 'bottom'},
 hAxis: {title:'Date'},
 curveType: 'function'
 }
 }; 
 var scoreCardConfig = {
 'divContainer': 'scorecard',
 }; 
 var sourceMediumTableConfig = {
 'divContainer': 'sourceMediumTableConfig',
 'query': {
 'dimensions': 'ga:source,ga:medium',
 'sort': '-ga:visitors',
 'max-results': 100
 }
 };
 function renderGraph() {
 baseConfig.query.ids = document.getElementById('tableId').value;
 dataOverTime.set(baseConfig).set(dataOverTimeConfig).render();
 scoreCard.set(baseConfig).set(scoreCardConfig).render();
 sourceMediumTable.set(baseConfig).set(sourceMediumTableConfig).render(); 
 document.getElementById('ui').style.display = 'block';
 return false;
 }
 </script>
 <script type="text/javascript">
 var _gaq = _gaq || [];
 _gaq.push(['_setAccount', 'UA-33166458-1']);
 _gaq.push(['_trackPageview']);
 (function() {
 var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
 ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
 var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
 })();
 </script>
 <script type="text/javascript">
 var _gaq = _gaq || [];
 _gaq.push(['_setAccount', 'UA-32934024-1']);
 _gaq.push(['_trackPageview']);
 (function() {
 var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
 ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google.com/jsapi';
 var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
 })();
 </script>
 <script type="text/javascript">
 var _gaq = _gaq || [];
 _gaq.push(['_setAccount', 'UA-32934024-1']);
 _gaq.push(['_trackPageview']);
 (function() {
 var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
 ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://') + 'analytics-api-samples.googlecode.com/svn/trunk/src/reporting/javascript/ez-ga-dash/gadash-1.0.js';
 var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
 })();
 </script>
 <script type="text/javascript">
 var _gaq = _gaq || [];
 _gaq.push(['_setAccount', 'UA-32934024-1']);
 _gaq.push(['_trackPageview']);
 (function() {
 var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
 ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://') + 'apis.google.com/js/client.js?onload=gadashInit';
 var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
 })();
 </script>
 <button id="Button1" style="visibility: hidden;">
 Authorize Analytics</button>
 <hr />
 <p>
 Enter your Table ID:
 <input type="text" id="tableId" />
 <button onclick="return renderGraph()">
 Draw Charts</button></p>
 <hr />
 <div id="ui" style="display: none;">
 <h4>
 Data Over Time</h4>
 <div id="dataOverTimeConfig">
 </div>
 <h5>
 Totals for each metric</h5>
 <div id="scorecard">
 </div>
 <h5>
 Source and Mediums by Visitor</h5>
 <div id="sourceMediumTableConfig">
 </div>
fernandopasik
10.7k7 gold badges52 silver badges56 bronze badges
asked Jul 7, 2012 at 9:23
1
  • Did you have any success doing this? I'm trying to do the same to build some reports for clients and want to avoid the login process as they get confused by it! Commented Jul 16, 2012 at 10:48

2 Answers 2

2

You can use Google Analytics superProxy to share data with users who are not authenticated.
You can create queries to Analytics with superProxy and then use the data stored with superProxy to construct your charts. I ran into the same problem, and this was the only solution I could find.

https://developers.google.com/analytics/solutions/google-analytics-super-proxy

answered Aug 23, 2014 at 0:51
Sign up to request clarification or add additional context in comments.

Comments

0

Can you share more information about how you access Google Analytics?

Check out http://code.google.com/p/google-api-javascript-client/wiki/Authentication on how to set authentication. Note that your credentials are visible in JavaScript, so make sure you create a user with just the minimal permissions you need

answered Jul 8, 2012 at 7:09

Comments

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.