[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.javascript

Google Analytics API from JavaScript

Gitin Kakkar

7/15/2014 12:09:00 PM

How can we access and use Google Analytics API from Javascript so that I access all analysis of my website from backend??
6 Answers

Evertjan.

7/15/2014 3:21:00 PM

0

Gitin Kakkar <gitin.k@gmail.com> wrote on 15 jul 2014 in
comp.lang.javascript:

> How can we access and use Google Analytics API from Javascript so that I
> access all analysis of my website from backend??

Is this an exam question?

Do you mean Javascript serverside or clientside, or both?

Read the guides and develop what you want:

<https://developers.google.com/analytics/devguides/repo...

--
Evertjan.
The Netherlands.
(Please change the x'es to dots in my emailaddress)

gitin.kakkar

7/16/2014 1:06:00 PM

0


server side.

Evertjan.

7/16/2014 3:20:00 PM

0

gitin.kakkar@paytm.com wrote on 16 jul 2014 in comp.lang.javascript:

[please quote whay you are replying on,
this is usenet not some GGroup.]

> server side.

On what server platform, ASP perhaps?


--
Evertjan.
The Netherlands.
(Please change the x'es to dots in my emailaddress)

gitin.kakkar

7/17/2014 5:04:00 AM

0

I am working on Linux.

gitin.kakkar

7/17/2014 5:57:00 AM

0

On Thursday, July 17, 2014 10:34:22 AM UTC+5:30, gitin....@paytm.com wrote:
> I am working on Linux.

var googleapis = require('googleapis');
var client;
googleapis
.discover('plus', 'v1')
.execute(function(err, data) {
client = data;
});

var CLIENT_ID = googleapis.client_id;

var CLIENT_SECRET = googleapis.client_secret;
CLIENT_ID='xxxxx.apps.googleusercontent.com';
var oauth2 = new googleapis.OAuth2Client(CLIENT_ID, 'postmessage');

var SERVICE_ACCOUNT_EMAIL = 'xxxx@developer.gserviceaccount.com';
var SERVICE_ACCOUNT_KEY_FILE = '/key.pem';
var jwt = new googleapis.auth.JWT(
SERVICE_ACCOUNT_EMAIL,
SERVICE_ACCOUNT_KEY_FILE,
null,
['https://www.googleapis.com/auth/analytics.rea...]);

var client;


googleapis
.discover('analytics', 'v3')
.execute(function(err, data) {
client = data;

jwt.authorize(function(err, result) {
//console.log(result);
oauth2.setCredentials({
access_token: result.access_token

});

client.analytics.data.ga.get({
"ids": "ga:id",
"start-date": '2014-06-15',
"end-date": '2014-06-30',
"metrics": "ga:users",
"dimensions":"ga:userType,ga:browser,ga:browserVersion"
})
.withAuthClient(oauth2)
.execute(function(err, result) {
console.log(result);
});
});
});


This code is running but it always returns NULL, it may be because it is not able to retrieve anything from GA. Kindly help.

Evertjan.

7/17/2014 7:14:00 AM

0

gitin.kakkar@paytm.com wrote on 17 jul 2014 in comp.lang.javascript:

> I am working on Linux.

Can a linus server use javascript?
On a server a "platform" in my view is not the operating system
but the serverside implementor of web-serving.

Sorry, I will not go on with you,
if you do not quote where you are responding on.


--
Evertjan.
The Netherlands.
(Please change the x'es to dots in my emailaddress)