Monday, March 11, 2013

Onsubmit,Onclick Tracking code -Google analytics

First you need to write the definition code in head section of web page :-

<html>
<head>
<script type="text/javascript">

var _gaq = _gaq || [];

_gaq.push(['_setAccount', 'UA-17410704-2']);

_gaq.push(['_setDomainName', 'Website URL']);

_gaq.push(['_setAllowLinker', true]);

_gaq.push(['_trackPageview']);


(function() {

var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;

ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';

var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);

})();

</script>


  <script type="text/javascript">
function submitThis()
{
_gaq.push(['_linkByPost', document.form1]);  


</script> 

</head>
<body>

<form id="form2" name="form1" method="post" onsubmit="return submitThis();" action=""

target="_top">

<a href="URL1" onclick="_gaq.push(['_link', 'URL1']); return false;" class="navBtn">Modify / Cancel Reservation

</a>



 </form>
</body>

</html>

No comments:

Post a Comment