Reputation: 58
I found this api link to fetch stats for my goo.gl link :
I need to fetch only the value of all time : shorturlclicks parameter from that data. I have looked up enough. Not able to do so. Please help.
Upvotes: 0
Views: 476
Reputation: 126
You should do an API call to that endpoint and grab the data you need from the resulting object.
In jQuery that would look like this:
var gooUrl = 'http://goo.gl/vM44rY';
var requestUrl = 'https://www.googleapis.com/urlshortener/v1/url?shortUrl=' + gooUrl + '&projection=ANALYTICS_CLICKS';
var callback = function (data) {
// do what you need with the data here
var clicks = data.analytics.allTime.shortUrlClicks;
console.log(clicks);
}
$.ajax({
dataType: "json",
url: requestUrl,
success: callback
});
Upvotes: 1