PDA

View Full Version : How code GA link?



robertbaer
04-24-2014, 09:35 PM
Test program at http://www.oil4lessllc.com/Lindex.html:
.
.
<link rel="stylesheet" href="css/style.css" type="text/css" media="screen">

<script>
(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
})(window,document,'script','//www.google-analytics.com/analytics.js','ga');

ga('create', 'UA-19002128-1', 'oil4lessllc.com');
ga('send', 'pageview',
{'hitCallback': function()
{console.log('analytics done sending pageview');}
}
);
txt=navigator.userAgent;
ga('send', 'event', {
'eventCategory' : 'Browser Test',
'eventAction' : 'Get User Agent',
'eventLabel' : '/' + navigator.userAgent + ' ',
'hitCallback' : function () {
{console.log('/' + navigator.userAgent + '');}
}
});
</script>
<!-- note first arg is the LINK desired and it is used in the timeout() -->
<script type="text/javascript">
function doOut(link, category, action) {
try {
var myTracker=_gat._getTrackerByName();
_gaq.push(['myTracker._trackEvent', ' + category + ', ' + action + ']);
setTimeout('document.location = "' + link.href + '"', 800)
}catch(err){}
}
</script>
</head>
.
.
<div class="box1">
<img src="images/1page_img1.png" alt="Codatron&trade;HT">
<h2>Codatron&trade;HT</h2>
<p>The Codatron&trade;HT shunt HV regulator is our most popular product, especially in downhole applications. <br /></p>
<a href="CodatronHT.pdf" class="link">Open the PDF</a>
<!-- * want to do something like this, and work:
<!-- onClick="doOut(this, 'CodatronHT.pdf', 'PDFht');return false;" -->
<span class="box1-sh"></span>
</div>

So, in style,css i made the following ignorant mod on .link:

/* Buttons */
.button{display:inline-block; font:20px/24px 'Alegreya', serif; color:#5a5a5a; background:url(../images/btn.png) 0 0 no-repeat; padding-left:33px; padding-bottom:1px;}
.button:hover{ color:#000; text-decoration:none;background:url(../images/btn.png) 0 -26px no-repeat;}
.link{ display:inline-block; font:bold 12px/15px Arial, Helvetica, sans-serif; color:#ffffff; padding:9px 15px 8px 13px; background:#313131; border-radius:3px;
onClick="doOut(this, 'CodatronHT.pdf', 'PDFht');return false;"
}
.link span{background:url(../images/btn2.png) 0 0 no-repeat; display:inline-block; width:3px; height:5px; margin:5px 5px 0 0;}
.link:hover{ text-decoration:none;background-color:#44d0f9;}
.link2{ color:#000; text-decoration:underline;}
.link2:hover{ text-decoration:none;color:#44d0f9;}
.link3{ display:inline-block; font:bold 18px/22px Arial, Helvetica, sans-serif; color:#5a5a5a;}
.link3:hover{color:#44d0f9; text-decoration:none;}

Would that work, or is something else needed?