Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to trigger Google Analytics from code?

My app reads an (html) file from my website, and I would like to track accesses to that file using Google Analytics. As the GA Javascript does not get executed when reading the file, it is not tracked. Is there a way to trigger GA directly from code or alternatively, to execute the Javascript from a .NET app without adding a bunch of dependencies?

like image 657
Han Avatar asked Apr 29 '09 21:04

Han


1 Answers

Google Analytics works by making a webrequest through javascript back to Google's server. If you want to do this programmatically, you just have to make this web request yourself. I would use Fiddler or FireBug to capture what the request looks like when you load the page in your browser. Then you can use that same URL in your .Net app.

like image 142
David Avatar answered Sep 28 '22 05:09

David