How to Get Stats & Charts from Alexa (Part 1)

by on June 21, 2011

Alexa is a very popular and free service for ranking website traffic. They compute traffic statistics by analyzing the web usage of millions of browsers which have installed their proprietary add-ons and plug-ins. The most well-known of these is the Alexa Toolbar.

But to webmasters and bloggers, Alexa's ranked measurements can be an important element in leveraging our site's popularity as a selling point to advertisers, sponsors, buyers, and readers. Plus, because their data is readily open to public review, the status of top ranks and/or climbing trends is a coveted (and often competitive) objective.

The lower the Alexa ranking number, the more heavily visited the site. Some current examples are: Google (1), Facebook (2), YouTube (3) … Wikipedia (7) … Twitter (9) … Amazon (17), and WordPress.COM (18). As with lower traffic sites, these top positions are constantly shifting.

In this article series, we'll start by discussing basic background information. Then, we'll develop PHP functions and WordPress shortcodes which gather data and images using undocumented Alexa services. You can easily present these numerous statistics and various charts on your own site, publicly or privately. Please note that attribution MUST be given to Alexa for the data presented, preferably with at least one link.

Advanced developers may want to skip ahead to grab these functions … 700+ lines of source code. In this article series, we'll explain it all … revealing, along the way, both coding tricks and undocumented Alexa access secrets. The easiest implementation is to put the collection in your theme's functions.php file (within php tags).

Table of Contents for this Article Series
    Toggle Article Details

  1. Introduction: Alexa Data Overview  (you are here)
  2. (coming soon) How to Get Stats & Charts from Alexa (Part 2)
  3. (coming soon) How to Get Stats & Charts from Alexa (Part 3)
  4. (coming soon) How to Get Stats & Charts from Alexa (Part 4)

A Breif Overview of Alexa

Founded in 1996, Alexa Internet, Inc.  is a California-based subsidiary company of Amazon.com (acquired in 1999). Their name was chosen in homage to the ancient Library of Alexandria … drawing a parallel between the largest repository of knowledge in the ancient world to the modern-day, tantamount potential of the Internet.

In addition to collecting traffic data with their browser add-ons, they also crawl virtually every site on the web archiving pages in their ever-expanding database. Currently, with more than 100 terabytes and 10 billion web pages archived from 1996 to the present (using their ia_archiver webbot), their donated data serves as the basis for the Wayback Machine which lets users view historical snapshots of most the Internet.

Alexa generates revenue from advertising and SEO Site Audits. They also offer two very low cost data feed services: Alexa Top Sites and Alexa Web Information Service. The techniques that we use in our code are a free, but currently undocumented  subset of the extensive AWIS programming service.

Alexa Traffic Data Collection

Alexa is sort of like the Internet's version the Nielsen Ratings (which tracks the popularity of TV shows). And in a manner similar to the Nielsen Ratings, Alexa's ratings analyze measurements of the browsing traffic patterns of a representative number of people online (estimated to be 10-million+) and project those numbers to the whole internet.

Also, it is worth noting that Alexa specifically states they not attempt to analyze web usage data to determine the identity of any user. You can peruse their Privacy Policy here.

Because Alexa's add-ons (which measure the traffic patterns) tend to be installed in the browsers of tech-oriented surfers, such as bloggers and webmasters, the raw data samples are clearly skewed. However, the service does utilize data-normalization strategies to compensate for this differential. You may be interested in reading their own Traffic Stats FAQ and Traffic Rankings Explanation.

Add-ons Available from Alexa

With this information in mind, it's a very good idea to install their toolbar add-on for your browser. This way your own traffic on your site will be included. It's available for Chrome, Internet Explorer (M$IE), and Firefox … on Linux, Mac, and Windows desktop operating systems.

Their toolbar specifically for Google Chrome is actually a small popup window. It's activated by clicking their icon at the top-right of the browser.

In April of this year, Alexa added a custom Toolbar Creator. It's currently available for Firefox and M$ Internet Explorer. With this utility you can not only create a custom toolbar for your own usage; but, you can also offer it to your site's visitors. Using your own content and branding, visitors will have easy access to the links you provide. Introducing the Alexa Toolbar and Toolbar Creator FAQ provide more details.

As a matter of fact, we created our own toolbar. That's a link to it own the right … click the link to check it out. We have it packed with numerous useful links for web developers. Install it for a few days to see it improves your developer-centered web surfing. If not, simply uninstall it. But, I'm betting that you will enjoy the convenience of all the carefully organized web-dev links. Topics include links for:

  • all major online email services
  • the top 15 social media sites
  • the six key links for Google services
  • web statistics sites
  • the primary WordPress.org developer sections
  • developer references for CSS, CSS5, jQuery, PHP, and more
  • and, an assortment of online developer tools

So … whatcha wait'n for … go get it. The link automatically opens in a new browser tab.

As with virtually all toolbars, the offering from Alexa is inserted at the top of your browser. They have a low-profile, second option for Firefox users that resides in the statusbar … Alexa Sparky.

Alexa also has some widgets that you might want to include in your sidebar. I read recently that using their traffic badges log all of your visitors as if they were using the Alexa toolbar in their own browser. But, I seriously doubt this to be factual as it would obviously skew data collection toward your site and thereby invalidate their service. Nonetheless, I've installed a traffic badge myself just to see if it does make any difference.

Alexa Registration Benefits

It's also a good idea to register with the Alexa service. As an alternative, you can also login with your Facebook account. Once you do this, you can edit some basic information for your site including contact details, site title, and site description.

Plus, after registration, you can claim your site. It may take a few days for a new site to be listed, but this can certainly expedite your inclusion in their database.

Let's Look at a Sample of Data from our Shortcode

Now that we've covered the basic background information, let's get started with our PHP functions and WordPress shortcodes.

at alexa.com
Global Rank: 0
Page Views Daily: 1
Page Views Monthly: 30
Reviews Average: 0.0
Number of Reviews: 0
Help Us: Write a Review
Estimated Daily Earnings: 0.00
Estimated Mthly Earnings: 0.00
Estimated Site Worth: 0.01
Site Title: WP Code Snippets
Language: English
IP Address: 68.71.146.182
Host Name: gizmo.freedomzoneusa.com
Global Traffic Rank Trend
Daily Reach (percent)
Daily Pageviews (percent)

The live  data to the right is a quick usage example … it took five minutes to create this one. The really cool aspect is that you can arrange any piece of data any way you want and apply your own style preferences. Our example in the next article in this series demonstrates many more of the data elements that you can choose from.

Notice that we made a direct link out of our Global Rank.   You can do this with any of the scraped data. Likewise, we created a Write a Review link. BTW … as you can see … hinthint … we don't currently have any reviews at Alexa. So … we encourage you to help.

This week our site celebrates its three-month anniversary. In fact, I decided to code this utility after getting excited about our own rising Alexa trends.

When Alexa first listed this site in early April (about a week after our site was launched), our ranking was 26,666,708. Three months later our overall rank is 146,788 and we're trending in the 85K range. Not bad for three months … plus, I recently installed our own custom Alexa toolbar. Maybe this will help too.

We actually have five distinct shortcodes. [wcs_alexa_data] provides most of the collected data as individual mix-n-match elements.

[wcs_alexa_chart] displays any of 7 different charts each with various options, such as size, data range, and background color.

[wcs_alexa_favicon_image] simply inserts an HTML tag for the Alexa icon. [wcs_alexa_link] encloses any included content within a link to the Alexa rank page for the specified site. And, [wcs_alexa_review_link] works the same way, except that it wraps the content with a link to the Alexa review page for the specified site.

Here's the actual HTML for this quick sample:

Code: HTMLShortcode Example HTML

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
<table cellpadding="0" cellspacing="0" style="font-size:12px; border:1px solid #A0A0A0; padding:8px; background:#FFFFE8; -moz-border-radius:6px; -webkit-border-radius:6px; border-radius:6px; -moz-box-shadow:1px 1px 15px #C0C0C0; -webkit-box-shadow:1px 1px 15px #C0C0C0; box-shadow:1px 1px 15px #C0C0C0;">
    <tr>
        <td width="300" colspan="2" align="center" valign="top" style="padding-bottom:2px; font-size:16px; border-bottom:1px solid #A0A0A0;">[wcs_alexa site=http://wpcodesnippets.info data=favicon_image] [wcs_alexa site=http://wpcodesnippets.info data=alexa_link] [wcs_alexa_favicon_image]</td>
    </tr>
 
    <tr>
        <td width="150" style="padding-top:10px;">Global Rank:</td>
        <td width="150" align="right" style="padding-top:10px;">[wcs_alexa_link site=http://wpcodesnippets.info][wcs_alexa site=http://wpcodesnippets.info data=global_rank][/wcs_alexa_link]</td>
    </tr>
    <tr>
        <td width="150">Page Views Daily:</td>
        <td width="150" align="right">[wcs_alexa site=http://wpcodesnippets.info data=pageviews_daily]</td>
    </tr>
    <tr>
        <td width="150" style="padding-bottom:10px;">Page Views Monthly:</td>
        <td width="150" align="right" style="padding-bottom:10px;">[wcs_alexa site=http://wpcodesnippets.info data=pageviews_monthly]</td>
    </tr>
 
    <tr>
        <td width="150">Reviews Average:</td>
        <td width="150" align="right">[wcs_alexa site=http://wpcodesnippets.info data=reviews_avg]</td>
    </tr>
    <tr>
        <td width="150">Number of Reviews:</td>
        <td width="150" align="right">[wcs_alexa site=http://wpcodesnippets.info data=reviews_count]</td>
    </tr>
    <tr>
        <td width="150" style="padding-bottom:10px;">Help Us:</td>
        <td width="150" align="right" style="padding-bottom:10px;">[wcs_alexa_review_link site=http://wpcodesnippets.info]Write a Review[/wcs_alexa_review_link]</td>
    </tr>
 
    <tr>
        <td width="150">Site Title:</td>
        <td width="150" align="right">[wcs_alexa site=http://wpcodesnippets.info data=site_title]</td>
    </tr>
    <tr>
        <td width="150">Language:</td>
        <td width="150" align="right">[wcs_alexa site=http://wpcodesnippets.info data=language]</td>
    </tr>
    <tr>
        <td width="150">IP Address:</td>
        <td width="150" align="right">[wcs_alexa site=http://wpcodesnippets.info data=ip]</td>
    </tr>
    <tr>
        <td width="150" style="padding-bottom:10px;">Host Name:</td>
        <td width="150" align="right" style="padding-bottom:10px;">[wcs_alexa site=http://wpcodesnippets.info data=host_name]</td>
    </tr>
 
    <tr>
        <td width="300" colspan="2" align="center"><span style="padding-bottom:5px; font-size:12px;">Global Traffic Rank Trend</span>
[wcs_alexa_chart site=http://wpcodesnippets.info type=t width=240 height=160 bkg_color=#E8F0F4 style='margin-bottom:15px; border:1px solid #A0A0A0; padding=4px; -moz-box-shadow:1px 1px 10px #C0C0C0; -webkit-box-shadow:1px 1px 10px #C0C0C0; box-shadow:1px 1px 10px #C0C0C0;']
        </td>
    </tr>
 
    <tr>
        <td width="300" colspan="2" align="center"><span style="padding-bottom:5px; font-size:12px;">Daily Reach (percent)</span>
[wcs_alexa_chart site=http://wpcodesnippets.info type=r width=240 height=160 bkg_color=#E8F0F4 style='margin-bottom:15px; border:1px solid #A0A0A0; padding=4px; -moz-box-shadow:1px 1px 10px #C0C0C0; -webkit-box-shadow:1px 1px 10px #C0C0C0; box-shadow:1px 1px 10px #C0C0C0;']
        </td>
    </tr>
 
    <tr>
        <td width="300" colspan="2" align="center"><span style="padding-bottom:5px; font-size:12px;">Daily Pageviews (percent)</span>
[wcs_alexa_chart site=http://wpcodesnippets.info type=p width=240 height=160 bkg_color=#E8F0F4 style='margin-bottom:15px; border:1px solid #A0A0A0; padding=4px; -moz-box-shadow:1px 1px 10px #C0C0C0; -webkit-box-shadow:1px 1px 10px #C0C0C0; box-shadow:1px 1px 10px #C0C0C0;']
        </td>
    </tr>
 
    <tr>
        <td width="300" colspan="2" align="center">[wcs_alexa data=powered_by_image_link]
        </td>
    </tr>
</table>

 

Continue Reading…

We continue in the next segment with: How to Get Stats & Charts from Alexa (Part 2).

 

Share This Article: “How to Get Stats & Charts from Alexa (Part 1)”

(Also Available: Press CTRL+D to Bookmark this Page)

Comments

Share Your Thoughts  7 Responses to “How to Get Stats & Charts from Alexa (Part 1)”
  1. 1

    Thank you for sharing.I love every article of all.I know more something from your website.Very good website and very interested.

  2. 2
  3. 3

    Thanks you wpcodesnippetsi setup good

  4. 4

    When I originally commented I clicked the “Notify me when new comments are added” checkbox and now each time
    a comment is added I get three emails with the same comment.
    Is there any way you can remove people from that service?

    Thank you!

  5. 5

    I am really loving the theme/design of your web site. Do you ever run into any web browser
    compatibility issues? A handful of my blog visitors have complained about my website not
    operating correctly in Explorer but looks great in Chrome.
    Do you have any ideas to help fix this problem?

  6. 6

    The new soccer stadium is the final catalyst for what is certain to become one of the most
    vibrant and sustainable sports and retail districts in America,
    ‘ Gray said. With spring on the way, the horses are shedding like crazy – I was
    up to my ankles in reddish brown fur moments after I started grooming her.
    In the past, most leases had various built-in clauses that had their price adjusted to the CPI, which protected those who signed from inflation. Also it is against all safety
    rules to start a horse alone. Thus giving you a chance to invest now and make the most out of it later.
    They will provide you the best professionals like
    agents, realtors, brokers etc. A final type of property is the Ohana Dwelling or Grandma’s Cottage.
    Personal Real Estate Investor (PREI) Magazine asserts that IPX
    defined the difference among Realtor-centric turn-key
    property sales, turn-key rental sales, and full-cycle,
    full-service, turn-key investment providers. You may actually find some hidden treasures
    that could be rather valuable and prove to be profitable, letting you earn a little extra on the deal.
    Besides metro link the site is well connected to all parts of Delhi, Noida and
    Faridabad through road.

    Take a look at my site: ground lease rental rates

  7. 7

    bookmarked!!, I love yoսr blog!

    Feel free tо visit mʏ web blog; hack 8 ball pool

Share Your Thoughts

(Some editor features are restricted unless you're logged in.)

(When replying to a specific comment, your browser may require Shift+Enter instead of just Enter.)


(get a gravatar)


Notify me of followup comments via e-mail. You can also subscribe without commenting.