Google analytic is very powerful and handy utility provided by the Google to track your web site traffic from all over the word.
To use this Google analytic with our asp.net page we have to put one java script code into the page based on the WebPropertyId of the analytic profile from which we track our site.
Following are the some ready made methods of helper class which help you to play with google analytic into your asp.net page
Please download following assembly to use the helper class methods
Download - "Google Analytics Desbord Controls.dll"
1) getTrackerCode
GADCAPI.GADCAPIHelper.getTrackerCode(string WebPrppertyId)
This method return the java script which used to place into the page to activate google analytic tracker on that particular page.
Output:
var gaJsHost = ((""https:"" == document.location.protocol) ? ""https://ssl."" : ""http://www."");
document.write(unescape(""%3Cscript src='"" + gaJsHost + ""google-analytics.com/ga.js' type='text/javascript'%3E%3C/script%3E""));
try {
var pageTracker = _gat._getTracker(""U-XXXXXXXX-X"");
pageTracker._trackPageview();
} catch(err) {}
document.write(unescape(""%3Cscript src='"" + gaJsHost + ""google-analytics.com/ga.js' type='text/javascript'%3E%3C/script%3E""));
try {
var pageTracker = _gat._getTracker(""U-XXXXXXXX-X"");
pageTracker._trackPageview();
} catch(err) {}
(script tags are omitted because of post rendering made them activate)
2) getProfilesList
public static List getProfilesList(string EmailAddress, string Password)
This method get your analytic account user name and password and return generic List of Class ProfileInfo.
ProfileInfo is class which have following properties
1) Url - profile url
2) WebPropertyId - U-XXXXXXXX-X like unique code for profile given by the
analytic
3) ProfileId - this is profile id which is used to get profile data into the Google Analytic Dashboard Controls
Output:
URL | WebPropertyId | ProfileId |
---|---|---|
jigneshsuvariya.blogspot.com/ | UA-11462261-1 | 23177177 |
To find more utility control please refer the post Google Analytic Dashboard Controls into the category web control