Mashing Google Analytics With External Data
By Sal Uryasev
June 9, 2008
Find more about:
googleanalytics
reporting
google
A couple months ago, we put together a Greasemonkey tool that sucked data out of Google Analytics, and after mining it for trend information, integrated it back into the GA interface. This week's tool combines and extends Google Analytics with data from an outside source.
Here is a quick alpha of our Greasemonkey integration of external data reporting into Google Analytics for Kampyle, a "feedback analytics service." Click on the images to zoom in.
Clicking on the 'Kampylize' tab queries the Kampyle site in real-time to populate the standard GA data table.
Our friends at Kampyle run a service that allows website owners to put a feedback button on individual pages of their website. All information submitted by the user is uploaded to a central Kampyle database that compiles the user feedback with web page url and standard internet statistics such as the name of the browser. Website owners can access a server-end service that consists of a reporting site complete with summary data tables, graphs, and charts.
Since both sites are web-based reporting suites segmented in a similar fashion (individual website, date, web browser, etc.), they integrate together naturally. There is a lot of value in placing related data side by side, allowing users to get a more holistic picture of web site performance. If you have other ideas of data sources that would fit neatly with Google Analytics, let us know and we'll consider building the integration.
If you're interested in technical details, continue to Open Juice to see how this is all accomplished...
Tufte-Style Comparison Chart Generator
By Sal Uryasev
May 6, 2008
Find more about:
tufte
pil
comparison
chart
generator
Last week, we shared a rendition of a Tufte graphic using just a few lines of Nodebox code. As our commenters pointed out, Python is great, but it may not be every business analyst's carnal desire to learn a programming language just to generate some nifty graphs. I spent some time to push Chris's Nodebox rendition into a PIL-based Windows tool that can generate the same sort of comparison graph from an Excel file on the fly.
The result is The Comparison Chart Generator 1.0. The installation instructions are relatively simple. Unzip the zip file, and run comparisionchartgenerator.exe.
Alternatively, we have a new excel chart that creates the same effect using only excel functionality. Download the Excel Tufte Line Chart here.
If you are using the Chart Generator, start with some data in an Excel (xls) or Comma Delimited (csv) format. The data for this graph has to be contained within the first sheet starting with cell A1, as in the following picture.

Select an input file. There are a couple example files bundled with the download.

After selecting a file, you'll be prompted to modify a few of the basic options available for the chart.

Finally, save the result as a jpeg.

Here is the same image found in Tufte's textbook processed using the Comparison Chart Generator. It is generated using the csv example file bundled with the download.

Those of us who have undergone lasik eye-improvement surgery may still prefer the sharp crisp Nodebox results, but for the rest of us, this image looks pretty good. Let us know if this tool is useful. If there is enough of a positive response, we may consider expanding functionality for other fancy Tufte-esque charts.
If you do prefer Nodebox, I have an updated script here. This pushes the script up to 20 lines of code or so, but the extra 9 lines allow the labels to push themselves apart on their own. If you want to look at the source code for the Windows program, you can get it here. I used py2exe to compile it into an executable. The code, however, has not been thoroughly commented or cleaned as of yet, so edit it at your own risk.
18 comments | Show all comments only the last 5 are shown
lucas said:
Keep going, guys! I'm looking forward to seeing other Tufte-esque charts here.
And thanks a lot for the Nodebox, what a amazingly useful piece of software!
Asim said:
sal,
it took me a while to put all the pieces together. "using python...using excel..." but i realised that you may be interested in using resolver one:
http://www.resolversystems.com/products/
(i'm certain you've heard of it before, but let me describe it for the benefit of others)
it integrates a spreadsheet environment with a built in ironpython interpreter. that way, you wouldn't have to mess around with PIL and py2exe.
watch the one minute screencast:
http://www.resolversystems.com/screencasts/resolver-one-in-one/
and download it for free under a non-commercial license. big down side: only for windows (i'm a mac user, and don't enjoy working in a virtualised environment).
hope this is of interest to you, take care.
asim
Bilsko said:
Just tried it out on my Vista machine with Excel 2007 and it works great. Of course, I had to save the file as .xls so compchart could read it (it still baffles me that Microsoft had to go and introduce .xlsx as a file type...)
Rob said:
I just tried to run the .exe. file and got an error: "The specified module could not be found. Loadlibrary (pythondl) failed"
Any idea what this means and (more importantly) how to get around it?
Thx
johnny m said:
Awesome! However, all I get are export errors. But you have inspired me to begin to learn Python.
Traceback (most recent call last):
File "comparisonchartgenerator.py", line 247, in <module>
File "Image.pyc", line 1405, in save
File "JpegImagePlugin.pyc", line 409, in _save
File "ImageFile.pyc", line 493, in _save
IOError: encoder error -2 when writing image file
Madelaine said:
Cool, thanks. I might use this for gene expression data sometime.
derek said:
That's very nice. For extra sharp crispness, can you arrange for the imnage to be saved as GIF or PNG? Generally speaking, JPG is a very bad format to choose for graphs. The compression algorithm, which was designed for photographs with their smooth color gradients and few sharp edges, handles text, lines, and solid blocks, with their uniform fields of few colors, and many sharp edges, very badly, and the file is almost never as compact as a GIF acheives.
The image above shows the characteristic "newsprint smudged by fingers" visual effect of text in jpegs, and the file is 57K. You should find a lossless compression format both sharper in appearance and smaller in size.
Sal said:
I picked JPEG as a default since the PNG format is less known within Windows. Functionality for PNG is already included in the program, but is not obvious. When you are offered to save the file, ignore the *.jpg suggestion, and simply name it "whateveryouwant.png". You will have the output converted into the right format.
The GIF format is also built in if you want to try it out, but for some reason the PIL library that I used has not been creating great-looking GIF images. I would avoid them. The PNG looks very nice though.
derek said:
Thanks. Unfortunately, it may call itself a PNG, but it's still got jpeg artifacts. Also, bizarrely, the pseudo-PNG comes out at 60K compared to the jpeg's 40K.
There's no reason for such a simple graphic to have that kind of bloat. At the risk of tooting my own trumpet, see <a href="http://i146.photobucket.com/albums/r264/del_c/politics-charts/DoDDeaths3.png">this 800x600 graph</a>, which I think packs a fair bit more info into only 13.5K.
(and the <a href="http://i146.photobucket.com/albums/r264/del_c/politics-charts/DoDDeaths2small.png">400x300 thumbnail version</a>, designed to fit into the narrow column of a blog, is a mere 3.9K!)
Chris Gemignani said:
Derek,
We've had a number of problems getting a high quality image out of the Python Imaging Library (PIL). For this application, GIF would be best, but PIL was producing some ugly files.
Those graphics are really nice. Excel, too!
We use ImageMagick in house, but we can't package that in an app. A nice approach when using Excel is to output an image slightly bigger than you need then scale it down slightly with ImageMagick. This gives you anti-aliased lines and text that you don't get by default from Excel. It's what we used to produce the Colbert Bump graphs.
Nick said:
Hi,
This looks great! But for some reason the download link for the source for the windows version does not seem to work - I'd love to study the code, to learn how to use basic python to make my own tufte-esque charts.
Christian said:
Thank you for this post, it looks great! I love Tufte's work and read your blog frequently in Google Reader.
The output file (.png or .jpg) could be of a much wider use if it was a .wmf file, because this would enable me to change the colour of one line or text and make any additions I like with Illustrator. Is it possible to get a .wmf version? That would be fantastic.
Sal said:
Code should be accessible.
Most of the code deals with the GUI interface and with parsing excel/csv files. The actual PIL interaction starts around line 196.
I don't believe that PIL actually supports the wmf format. I am fixing up a presentable version of this sort of graph in Excel to add to the next version of chartchooser (http://chartchooser.juiceanalytics.com/). I'll put up a draft version of that when I have it cleaned up - it should be sufficiently editable to not need Illustrator.
Kasper said:
Great tool. One question: Is there a way to change the number of decimals shown? Currently it seems to show just on decimal, whatever the number format in the xls-spreadsheet.
Sal said:
As promised, I posted an excel chart of the same graph. You can find the link near the top of the page.
Jose Hernandez said:
I have an alternative post on a dynamic Excel bumpchart that combines charts with the cell grid. You can donwload it at http://sites.google.com/a/visual-catalyst.com/info_displays/Home/tufte_example_bumpchart.xls?attredirects=0
This display works for all versions of Excel. I'm working on a how to that describes how you can extend this type of chart.
Christof said:
Excellent work. I'm impressed!
John said:
awesome - using it right now. More Tufte style charting programs please!
Add a comment
Keyword Trends in Google Analytics With Greasemonkey
By Sal Uryasev
April 23, 2008
Find more about:
webanalytics
google
analytics
hack
greasemonkey
Note: We've updated the script to work on Firefox 3 as well as Firefox 2.
After the warm reception for the first version of our Enhanced Google Analytics, we decided to add some new functionality. (Nothing like a few kinds words to keep us in the giving mood.) The first script created a couple new tables in the Google Analytics interface that highlight recent changes in referral visits. It uses Greasemonkey, an add-on for Firefox that allows a user to insert javascript directly into a webpage.
Our update gives you even more ability to understand the data in Google Analytics:
- At the suggestion of Avinash Kaushik, the new script works for keyword data, helping you see how organic search traffic is changing. An increase in a keyword may indicate a general change in user interests and/or improved performance on search results.
- My coworker Pete Skomoroch also suggested that I add the ability to see declines in referrals and new keyword searches.
- With the help of Paul Irish, the script is now better able to interface with the date widget on the Google Analytics site.
(Click the above button for a simulation.)

When you click the button, your browser will download some historical data behind the scenes, and display a nice summary of the best and worst performing keywords/referring domains.
Installation Instructions:
Firefox 2.0+
Greasemonkey
googleanalyticsdownloade.user.js
If you don't already have Firefox, install it. Install Greasemonkey, and do the required Firefox restart. You should see a handsome monkey peeking at you from the bottom right hand corner of your browser. Open the script file in your firefox browser, and Greasemonkey should give you an option to install the script.
Afterwards, log into Google Analytics, and navigate to your Referring Sources or Keywords Tab. Click the button.
Configuring the script:
We spent some time trying to find convenient default settings here at Juice Analytics, so the script should work straight out of the box. Some users, however, may find it convenient to alter some of these configurations. To do so, in Firefox, go to Tools=>Greasemonkey=>Manage User Scripts..., select Google Analytics Downloader, and then click Edit in the lower left corner of the window. This should open up the script file in a text editor. If your computer does not have a default text editor configured, you may have to choose one. 'c:\windows\notepad' is a good bet for Windows machines.
This is what you should see:

The bracket labeled 'keywords?' controls defaults for the Keywords page, and correspondingly, 'referring_sources?' controls the Referring Sources page.
To change the settings, simply change the corresponding variable to your preferred default. Make sure to refresh your Google Analytics webpage, if you have it open, so the new settings are loaded.
Now for the nitty gritty configuration details:
- display_limit: This controls the maximum entries that each table will contain. This may be useful for large, sprawling sites.
- growth_tolerance: This is the percentage growth parameter. Changing it to .10, for example, will catch everything that has grown by 10%, as opposed to the default 50% and 20%, respectively.
- minimum_number_elements: This is a significance benchmark that can be used to limit what is displayed upon the screen. By default, only keywords with at least 10 elements are displayed upon the screen. Referring Sites does not have a minimum by default, but one can be set if desired.
- limit: Limit is more of an internal parameter that determines how many entries should be downloaded from Google in order to get the results that are visible here on the page. Lower the limit to increase speed. If the limit is set to a very high number, you will get the largest result set, but you will have to sit around for a while for the results to load. Since the results are downloaded ordered by volume, raising the limit from the default numbers will not actually give more significant results. You will simply get more of the smaller results, such as keywords with only 1 hit.
- look_back: This is a very important parameter. The script uses the date displayed upon your Google Analytics page to determine the full range that you want to consider in your results, but 'look_back' determines how many of those days are used for the significance test. So, say the range you have displayed in Google is March 23 - April 22 and your look_back is 7 days. The script will compare the average referrals for a given keyword from April 16-22 to the average from March 23-April 15, and will return the keyword only if the recent average is 20% higher than the rest of the time period. Thus, if you want to increase the total range of the data, change the dates on the actual webpage. Change 'look_back' only if you want to change the period of significance.
Happy analyzing!
11 comments | Show all comments only the last 5 are shown
Avinash Kaushik said:
Sal: Thanks so much for this enhancement to the first script, given all the attention on Search I think this is absolutely super valuable. I am on a recommendation overdrive on this (I have a two slides on Juice in my official presentations! :).
Thank you again, this is excellent.
-Avinash.
SM said:
Thanks for pulling these scripts together, very useful.
Patrick H. said:
This is great, thanks a lot for posting it. Very good addition to GA.
James said:
Why didn't google analytics do this months ago?
This is great!
I wear many hats at my company. As entertaining as it may be, I don't have the time to play in excel.
Thank you!
Brian said:
Great work guys! This is killer!
New to the blog, but you've won a reader. ;)
Sascha said:
Thats perfect man!
Please more of this awesome features :)
Best Regards from germany
Tim said:
Great tool! But sadly it doesnt work anymore in FF 3. Do you have an update?
Regards, Tim
spudart said:
Yes, I love this tool. Unfortunately ever since Firefox automatically updated itself from 2.0.0.14 to 2.0.0.15, it doesn't work anymore in 2.0.0.15. An update would make my day.
Sal Uryasev said:
Silly Firefox. Thanks for pointing it out!
The script should work if you reinstall it now.
Steve said:
I'm having trouble getting any results to return when running the script. In one week we have about 9,000 different keywords sending traffic to our site - any thoughts on configuring some of the settings to retrieve results? I just get the "loading..." button showing for minutes on end. Maybe increasing the growth_tolerance or lowering the limit?
michelle said:
I don't understand how to get grease monkey to work - i followed all the install directions fine... now that its installed though I don't know what to do... can anyone help me? not sure I'm even in the right place :/
Add a comment
Enhancing Google Analytics Using Greasemonkey
By Sal Uryasev
April 11, 2008
Find more about:
webanalytics
google
analytics
hack
greasemonkey
There is a new post with updates to the script. Find it here.
My boss Zach has a problem. Every four hours the craving strikes him. No matter where he is, he pulls out his shiny Macbook Pro and navigates to Juice's Google Analytics site. He pulls up the list of referrers to our site and meticulously searches for new domains. He has an freakish ability to pick out IP addresses that have never linked to us before. Even so, there had to be a better way.
I wondered whether Greasemonkey might be able to help. Greasemonkey is an extension for Firefox that allows users to install custom javascript when you visit a specific website. These scripts can add a delete button for Gmail, automatically display lyrics to your YouTube music video, or do pretty much anything else you would want to enhance the functionality of a website.
After poking around the subtleties of the Google Analytics interface, I came up with a little script that can identify the new referrals that Zach so desperately craves. When navigating to the "Referring Sites" section of Google Analytics, the script add the following button to the interface.

Pushing the button downloads all the referrer data for the date displayed in the Google Analytics range, as well as a similar set of data for the range up to, but not including, the last three days. The difference between the two data sources is used to calculate all of the results. The specific number of days can be changed by editing the first line of the script. Greasemonkey then displays the results in two tables above the original Referrer table. (Greasemonkey works entirely within your browser shell, so your data should be quite secure.)

The first table shows any sites that have displayed more than a 50% increase in visits over the last 3 days as compared to the rest of the time range. The second shows all new recent sites that do not appear at all more than 3 days ago. This can be quite useful to anyone, who, like Zach, absolutely needs to know about any new and exciting inbound links.
Installation Instructions:
Firefox 2.0+
Greasemonkey
googleanalyticsdownloade.user.js
If you don't already have Firefox, install it. Install Greasemonkey, and do the required Firefox restart. You should see a handsome monkey peeking at you from the bottom right hand corner of your browser. Open the script file in your firefox browser, and Greasemonkey should give you an option to install the script.
Afterwards, log into Google Analytics, and navigate to your Referring Sources Tab. Click the button.
19 comments | Show all comments only the last 5 are shown
John Henson said:
Sal,
Some really nice JavaScript. I really love to see stuff like this done with GA.
Would you mind if re-use your export logic (with credit)?
Thanks,
John
Sal said:
John,
Thanks for the kind comment. Feel free to reuse it at your leisure.
-Sal
Avinash Kaushik said:
Awesome enhancement!
I am also afflicted with the same disease as Zach, and now I have a easy cure!
Absolutely love it.
Thanks,
Avinash.
Paul Irish said:
Just took a look at the code to scrape the new date without changing the URL...
var DI = new unsafeWindow.DateInputView;
var startdate = DI.parseDate(DI.primaryBeginField.value)
var enddate = DI.parseDate(DI.primaryEndField.value)
I didn't test this within the context of the script, but it hands back some nice Date objects that you can play with... hopefully it simplifies things for you.
:)
Sal said:
Thanks Paul!
I added some increased date functionality built upon your suggestion.
Al said:
Great tool, nice features!
Thank you.
Al
Tim Leighton-Boyce said:
This is extremely useful, thank you. This certainly helps gain some clearer insight by cutting through the usual suspects and highlighting the items of interest.
Rich said:
This is so cool - thanks to Avinash for pointing it out and of course the juice team for building this functionality!
Matthew said:
I'm not a programmer but like the Greasemonkey script. If I wanted to change the number of days it looks back to 30 rather than 3, do I just make the following change? "look_back = 30"
Chris Gemignani said:
Matthew,
We've got a new script coming probably tomorrow with a few new features. We'll address customization in that post. It really isn't hard. :-)
Tim said:
Hi,
I read about the script and desperately want to have it. I just couldn't make it work. I installed Greasemonkey, installed the script and restarted the browser. Than I logged into my Google Analytics Account and looked at the referring sites report - no new buttom to click on.
Have I done something wrong? A little more detailed instructions would be helpful as I really want to use that script!
Thanks in advance,
Tim
Dave said:
I installed the script and it looks great! I'm always digging in to see who has sent us new traffic, so thanks! I'd like to make the "look_back" date different as well, but I don't know where to find the script to make that change and save it. Any help on where to find the installed script to edit it?
Josh Chambers said:
Thanks a lot! I'll be writing a blog post about this for sure. Great script.
Neerav said:
thanks for this excellent tool
Is there somewhere I can subscribe to keep up to date with new versions?
Sal Uryasev said:
Matthew/Dave: The new post (linked at the top of the page) should have the details you need.
Tim: It sounds as if you did everything correctly. Is the script visible if you go to Tools=>Greasemonkey=>Manage User Scripts?
Neerav: There really is no great way to subscribe to just this script. I will link in the relevant places if anything changes though.
Neerav said:
Hi Sal
Enabling the "subscribe to comments" plugin could help. That way you can post a comment saying there's a new version and everyone who commented gets that comment as an email
Tim said:
Hi Sal,
thank you so much - I just reinstalled it and now it works! This is really fantastic!
Thanks,
Tim
Nate Sidmore said:
Awesome tool Sal, (thanks to Avinash for the tip).
I did run into a problem with the Firefox pop-up message "Warning: Unresponsive script". However that problem can be solved by lengthening the time allowed for scripts to run. For more details go to http://lifehacker.com/software/firefox/put-off-firefox-15s-unresponsive-script-dialogue-162574.php
However I was bummed when after setting the time allowance to 10 minutes, and clicking the "Who Sent Me Unusual Traffic" button in GA, the script ran for 9 min 38 sec before returning results. Any tips on getting quicker returns?
Chris Gemignani said:
Nate:
Thanks for the encouragement. If you check our "Keyword Trends" Greasemonkey script (linked at the start of this post), we write about how to change the parameters in the script to make things run faster.




0 comments | Add a comment
said: