HowTO: Google Analytics on RedBubble

Google Analytics (GA) works by doing two things. Passing information from a cookie to GA and by downloading a small image file from GA.

Because GA uses Javascript you can’t simply add the code to your RedBubble site. However, you can link to an image file on another server, and that opens the door to using a file on another server to pass information through to GA via the image download function.

I found this post that explains how to do this. The post also provides php code. I’ve created this brief walk-through for RedBubblers

Here is what you need to use this method:

  1. A server where you can add a php file, a directory, and image files at will.
  2. The ability to redirect on that server
  3. A new GA urchin number. (You don’t want to corrupt the statistics of another site)

Here’s the idea.

Joe Visitor loads up your redbubble page. On that page there is a link to an image file: ! ! The tracker directory doesn’t exist, instead there is a command to redirect that image file to a php file called track.php. Track.php passes along the file that’s being loaded to GA and gives Joe the new image url, which is

Okay, here’s the technical stuff:
In .htaccess you need to add the following line:

  • RewriteRule ^tracker/(.*).gif$ /track.php?url=$1&filetype=gif

This is what causes Joe’s browser to load track.php instead of /tracker/main.gif

Now you need to edit your php file. Copy the php code from this blog post.

There are three lines you MUST update for this to work:

  1. Line 2: $var_utmac=‘UA-0000000-0’; (Enter your urchin code)
  2. Line 3: $var_utmhn=‘’; (This need to be the same address you used when you signed up for GA)
  3. Line 32: $imageurl = fopen (‘’.$_G&#8... (Change the address to where the images are actually located)

After you’ve edited it, rename it to track.php and upload it to the root directory of your Web server.

Add a gif file to called test.gif (remember, the redirect is setup to work with gif files).

Then go to you should be redirected to and you should see the test.gif image shown. If the image is shown everything is working! If you get php errors then there is something wrong with your php file. If you get a 404 error your redirect isn’t working.

Test two: Add ! ! to your RedBubble profile page. Reload your profile page to see if test.gif appears.

If you pass both these tests then you know your redirect and php file are working.

Now, you’ll want to add a transparent 1×1 gif to your directory so that you can load an image that isn’t intrusive to your profile. You can download one here (right click and save as).

Add a link to that clear image to every page you want tracked.

You should notice redirections from immediately in your redirect log file. However, GA information won’t show up for at least a few hours. (The date defaults to yesterday in GA, so to check that you are getting results set the date to today.)

It’s important to note that using this method will only tell you which image files on are looked at. Every single visit will come from the server where is hosted. You won’t get any referral information, visitor location information, etc.

If you use the same image file for every page you’ll simply get a list of how many times that file has been viewed. If you create a different image file for each page you want tracked you can see how many times each page is viewed. You will also see what days and times of day the files are viewed.

I’m looking into ways of getting more information passed from Joe to GA to make this more useful. If anyone has any ideas or suggestions please let me know!

Journal Comments

  • Faizan Qureshi
  • Paul McClintock
  • ArtistaStyle
  • Mile High Mason Designs
  • easycherry