I came across this question when I checked my official mails this morning.
Problem: How to Set Goals in Google Analytics for Facebook Apps Thank you page?
Description : Why it is a problem? as there is only one static URL in Facebook Apps, So we can not use it as Thank you page in Goal Settings. One single solution that 1st came into my mind was to use the domain URL of apps where it is hosted as Facebook is fetching it from iFrame so if we use the domain URL of apps it may work, but life ain’t that simple, the apps we created is with Like Gate which means we can not proceed to further pages unless we like the page and in domain URL there is no way to get into further pages, also I tried to get URL manually but all it came as .tpl format and once I hit the enter .tpl file get downloaded.
Solution: When I discussed it with my team, many went into deep thinking mode of how to solve this problem, But one came with easy solution.
_trackPageview()method along with a URL you fabricate in order to track clicks from users that do not lead to actual website pages on your site. In general, we recommend you use Event Tracking for tracking downloads, outbound links, PDFs or similar kinds of user interactions. This is because virtual pageviews will add to your total pageview count. However, if you want to configure goals based on clicks to PDFs or downloads, you need to use this method (but be aware that these clicks will be tallied as part of your overall pageview count). For tracking Flash or Silverlight content, we recommend that you use the Adobe Flash Tracking library or the Microsoft Silverlightcomponent.
We need to add this line –
You can replace “/downloads/pdfs/corporateBrief.pdf” in the example above with any URL or filename you choose.
Here is how the Google Analytics Code may look like –
// _gaq.push(['_trackPageview', '/downloads/pdfs/corporateBrief.pdf']);
ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
var s = document.getElementsByTagName('script'); s.parentNode.insertBefore(ga, s);