Display Bit.ly stats using API 4.0 and JQuery part 2

Bit.ly API 4.0 and JQuery

Today we continue to build another feature to our Bit.ly API. Stats.

If you are new to Bit.ly API, I recommend that you read the Create short links using Bit.ly API 4.0 and Jquery Part 1 before going ahead to read this. We will also be making use of previous files to build the stats.


Let’s start coding how to display Bit.ly stats using API

In this tutorial, we are going to display two types of stats.

  • stats from referring domains
  • stats for the past 30 days


Stats from referring domains

I have created another tab at the top call “check stats” and maintain the same interface as the shorten for the stats tab.

Bit.ly API 4.0 and JQuery P2

First let copy the code and paste it inside your script


This API will return you two values

  • one is the referring domain
  • the other one is the number of clicks

    Bitly-API-4-and-JQuery-P2-1

I have created a new variable call total_clicks to store the sum of all the clicks. When the result is been displayed, the individual clicks will be added to the total_clicks variable and the total clicks will display on the last row.

The result will be like this

Bitly API 4 and JQuery P2 result

Now we are going to do the second part of the coding: stats for the past 30 days


Type in the following code

What the code above does is to draw the data from the past 30 days. Since I’m only interested in the number of clicks and when the clicks are been triggered, it will only display the data when the two rules are true.

The result will be like this

bitly stats 2

Hope you find displaying of stats using Bit.ly API 4.0 and JQuery useful to you and bring more productive to your work flow.

Do help to share this to more of your colleagues and friends.

Share

facebook icon twitter icon linkedin icon what app icon

Comments