Google Analytics Cross domain Link Tracking using jQuery

Google Analytics is usually the first tool most ecommerce websites use to track performance of various marketing strategies, whether it’s paid search (PPC), Affiliate marketing, landing pages or simply Organic Search. Many eCommerce websites also transfer visitors to external websites to complete the order and that creates a real challenge to track conversion rates.

Google Analytics provides the script to track cross domain conversions but that might become a pain to implement on all pages if that is not implemented nicely. That script needs to be called every time a <form> is posted to the external website or 3rd party shopping cart using onsubmit event or a link is clicked that points to that external website using onclick event.

The code below is the usual Google Analytic asynchronous script that is placed right before </head> tag with some additional parameters.

<script type=”text/javascript”>
var _gaq = _gaq || [];
_gaq.push([‘_setAccount’, ‘UA-XXXXX-X’]);
_gaq.push([‘_setDomainName’, ‘none’]);
_gaq.push([‘_setAllowLinker’, true]);
_gaq.push([‘_setAllowHash’, false]);

(function() {
var ga = document.createElement(‘script’); ga.type = ‘text/javascript’; ga.async = true;
ga.src = (‘https:’ == document.location.protocol ? ‘https://ssl&#8217; : ‘http://www&#8217;) + ‘’;
var s = document.getElementsByTagName(‘script’)[0]; s.parentNode.insertBefore(ga, s);

Now here’s our life saver!  If you are familiar with jQuery and use it on your website. Just place the following code in any javascript code block in your page, and make sure this script gets called in all pages by using some header file or template. The following script will add GA link tracking information to to all <form> and <a> tags posting to or

<script type=”text/javascript”>
jQuery(document).ready(function($) {
_gaq.push([‘_linkByPost’, this]);
_gaq.push([‘_link’, this.href]); return false;

How to verify that Link Tracking is working

The sole purpose of link tracking is to pass (GA) cookie information to the external website (shopping cart, storefront, payment processor etc.). If the code is implemented properly, you should be able to see the cookie information passed using additional URL parameters to external website.

Get All Column Names using Classic ASP Recordset Object

If you are looking for a quick way to display all column names contained by an ADODB recordset with the corresponding values. Here’s your code to do that in plain VBScript. This will retrieve all ADO Recordset fields and display those in an HTML Table.

mySQL="SELECT top 10 * FROM users"
Set myRS=Con.Execute (mySQL) ' Uses any ADODB connection

Response.write "<table><tr>"
For each item in myRS.Fields
 response.write "<th>" & item.Name & "</th>"

Response.write "</tr>"
While Not myRS.EOF
 response.write "<tr>"
 For each item in myRS.Fields
  Response.write "<td>" & cstr(myRS(item.Name)) & "</td>"
 response.write "</tr>"
response.write "</table>"

Note: I have added cstr function to the original code due to the type mismatch error while reading integer columns from database at the time of concatenation with (string) html tags.


Get every new post delivered to your Inbox.