Automotive Digital Marketing

Professional Community for Car Dealers, Marketing, Advertising and Sales Leaders

Loading... Be Patient!

Google Analytics - Facebook Fan Pages; How To Install Tracking Code

How to Install Google Analytics on Your Facebook Fan Pages for Better Visitor Tracking...

SOURCE: Posted by iphp on Feb 22, 2010 Thanks to ADM Blog Referral by Ron Morrison

We launched our Facebook fan page earlier this month and as with all Facebook pages only Facebook Insights program is available to page administrators. Facebook Insights shows demographic details and interactions on your pages BUT limited to show information of fans only. It is far less sophisticated and comprehensive when compared to the free Google Analytics. One of the limitations of Facebook Fan pages is that you can only run limited Javascript on it and Google Analytics needs Javascript code included to correctly track visitors. We have successfully managed to get ALL functions of Google Analytics working on our Facebook fan page (including visitor statistics, traffic sources, visitor country, keyword searches with all other powerful reporting & maps overlays etc).
Google Analytics Example

Google Analytics Example

How to setup Google Analytics on your Facebook fan pages

The workaround we use in our code is to include Google Analytics as an image instead of setting the standard Javascript. This method tracks every visitor to the custom facebook pages on Google Analytics. It required a combination of server side cookie management and an additional <img> tag to the bottom of the facebook fan page. Here are the steps to get Google Analytics working on your facebook fan page.

1) Setup Google Analytics account. If you already have one, create a new website profile. You can name it or You will finally get your tracking code which looks like this: UA-3123123-2

2) Create your custom img tag for each of your pages you like to track. EG: contact form, services, products etc. You can use our tool to create the Google Analytics link generator for Facebook pages.

3) Add the entire custom image html tag from step 2 to the bottom of each Facebook fan page that you need to track.

That is all there is to it! Google Analytics is not real-time, so you will need to give it some time. Approximately a day before you see the fruits of your “hard” work.

For advanced users

Use this method, if you don’t want to use our hosted link redirection as mentioned in the method above. You can download the entire source code which is just about three files to get this setup working on your own server (running PHP4.3 or above). The code is written in PHP and essentially creates the Google image tracking URL with the referrer, page information, ID, etc. The additional advantage of hosting this on your own server and domain is that visits from your website to your facebook fan page gets tracked, etc. You will also be able to customise further if you wish. Please do share any useful updates you apply to the tracking link code.

Facebook - Google Analytics Tracker v1.1 (Updated 21st Feb, 2010). For advanced method - Download this code to use on your server.

If you don’t have a Facebook fan page yet, visit our tutorial for code and help on creating customised Facebook fan pages.

PS: We could not find any other source / blog that described how to get Google Analytics on Facebook fan pages! There is support for canvas pages and applications but nothing for StaticFBML fan pages. Hope this helps and please leave your comments below.


1) A lot of users have asked how to track visits to the wall. Yes, this can be done. Please see the comments by iphp below.

2) Here is a screenshot to a staticFBML where the code should be placed

If you use the advanced option of hosting the code by yourself, you will be able to track visits from your website to your fan page and back. Also preserving the original referrer to your website, etc. It might also be better than relying on our servers.

Also, to clarify, the images generated from the server is loaded by the actual user and not Facebook. Also static FBML cannot be changed for time, etc easily as Javascript onload is blocked

On our Google Analytics we are able to see which device was used (Iphone, Android, Firefox, etc). We are able to see the location, track usage with cookies, time on pages, track visits after some time, etc. This complements Facebook Insights well. Also note that the page created using StaticFBML is static and the URL cannot be changed all the time. Let me know if you have any ideas and please do share code improvements that you make. [...] server, you can download the PHP source and host it yourself (PHP 4.3 required). Please refer to Webdigi for more information.Just like Facebook Insights, Google Analytics doesn’t provide real-time [...]

Please read the our previous article on creating custom Facebook pages. You can then put your codes there.

Thanks! All you need is patience now. It sounds like you have done everything correctly. Google Analytics is not real time as mentioned in the post. If you come back tomorrow you should see your graphs work and you will also see “not installed” message disappear.

For those who want to test out Google Analytics, please put a link to your fanpage here you might get more visits to show up on Analytics. But please note, you have to wait for Google in any case.

Facebook fan pages request end browsers to display the image directly and are not cached by Facebook.

Theoretically, you should be able to use this anywhere. Facebook, myspace, etc if they allow you to place img tag and if the actual user browser is loading the image.

As the article points out, make sure you select create a new profile for a new website / domain in Google Analytics. If you don’t create a new profile code or exclude this data with filters from your existing profiles, the facebook GA data will come along with all your visitor / session / traffic sources data in your existing profiles… technical reason is cookies won’t align.

You can definitely track visits on your Facebook page Wall as well. You will have to create a new static FBML box and place the img tag html code in it. To see this in action, Go to our fan page wall, you will see a box on the lower left called Articles which has a Google Analytics tracking code.

After you create your new StaticFBML, go back to edit your fan page. Under Application Settings for the entry you created, you can remove tab and add a box. Once a box is added it will be displayed under the Boxes section. All you have to do is to click on the little edit icon and select “Move to Wall”.

Doing the above will place your tracking code into the wall page and you will be able to track users on your fan page wall! Its easier than I made it look. Give it a go!

Don’t worry about the longer string. The strings generated for google analytics are just to help you track which pages are being visited. Give google analytics some more time also try this trick if you have not already.

For those who can’t wait for 24 hours but have waited for more than 10 hours, you might see new stats pour in. On the dashboard you can change the date range by clicking on the down arrow.

If you want to make sure that the code you generated is correct. Just copy and paste the code within (quotes) ‘ ‘ after src= and put it on your browser. You should be redirected to google analytics and you will get a blank screen (because google image is a 1x1 pixel size. This is correct and not broken. Make sure you enter your Analytics code correctly. I have appended this article (updates at footer) with an image showing where the code should be placed.

We think Facebook is going to get rid of iFrames in staticFBML at the end of the month. We wouldn’t be able to do what you are thinking of anyway as an iframe will not have access to the rest of the comments.

To determine if you have setup things correctly, visit the img location on the code generated by your browser and it should redirect to Google analytics and show you a blank page.

If you need to track fan pages this is the only way to get Google Analytics working.

Please take a look at the screenshot. This is where the code will go:

This method can only be used to track places that you have access to make source code edits and img tag. Which is all of Facebook custom fan pages, wall, etc at the moment.


Views: 295

Tags: Analytics, Facebook, Facebook Analytics, Facebook Fan Page, Fan Page, Google, Google Analytics, How To


Oops... You need to stop "Lurking" on ADM and become a more genuine Automotive Professional by completing your membership registration. As a registered ADM Member, you can post comments, publish your own articles (be a star!) and start Forum discussions. Stop being an online "Peeping Tom" and JOIN ADM RIGHT NOW!

Join Automotive Digital Marketing

Comment by David T. Gould on March 25, 2010 at 4:22am
I hesitate to use any resource that is out of the US (ie. .uk) and requires their server and coding... even if it works now... they can change code at any time to include unexpected (possibly malicious) results. I don't doubt this is possible... I question the security.

Maybe one of our many social media vendors could look into this and provide a similar or better solution with a better sense of security.

Good Selling! DTG

Automotive Professional Network and Resource Exchange for Car Dealers, Managers, OEM and Marketing Practitioners seeking Best Practices.

ADM Sponsor

William B. Terry
Rated by Super Lawyers

loading ...

ADM Badge


Based On Your Interests...

ADM Consulting, LLC

Onsite/Offsite Combination ADM Consulting, LLC Professional Services
Select the maximum monthly investment you plan to make
Sign up for

Automotive Marketing Tools

Get ADM Toolbar

Click here to take the ADM Member Survey

Getting too many emails from ADM? Click mailbox below to control which types of alerts and updates you are sent......



ADM Professional Services
Phone Consultation
Topic or Issue:

Top Automotive Marketing Forum Discussions

Share the Best Content w/AutoMarketing Community

© 2020   Created by Ralph Paglia.   Powered by

ADM Badges  |  Report an Issue  |  Terms of Service, pub-1344093271332697, DIRECT, f08c47fec0942fa0, pub-1344093271332697, DIRECT, f08c47fec0942fa0