Hi David,
Came across this article "How do I manually track clicks on outbound links?" http://adwords.google.com/support/bin/answer.py?answer=55527&cbid=-1h7aavbt2trys&src=cb&lev=answer and am wondering would it be possible to implement this into pricetapestry ? Not too sure if there is much involved.
Thanks
Adrian
Hi Adrian
How do you find the click tracking that Google provides?
Could one use this for billing Merchants on a Per Click basis?
Thanks
Andrew
Hi David,
Happy New Year to you :-)
I was reading a really good article today about Google Analytics and it reminded me that I should really setup outbound clicks as goals!
I noticed there was another thread on implementing Google Analytics using jump.php but this seems like a much more simple setup.
Is it possible to track Goals using what you've outlined above?
Thanks
Neil
Just set this up (with a lot of help from David) using the event tracking in GA and thought I'd share my finished solution.
First of all I placed the following in the head section(as suggested here http://www.google.com/support/analytics/bin/answer.py?answer=55527 ):
<script type="text/javascript">
function recordOutboundLink(link, category, action, label) {
_gat._getTrackerByName()._trackEvent(category, action, label);
setTimeout('document.location = "' + link.href + '"', 100);
}
</script>
Then I replaced the buy_url code in tapestry.php with this:
function tapestry_buyURL($product)
{
global $config_baseHREF;
global $config_useTracking;
if ($config_useTracking)
{
$href = $config_baseHREF."jump.php?id=".$product["id"];
}
else
{
$href = $product["buy_url"];
}
$href .= "' onClick=\"recordOutboundLink(this, 'Outgoing', '".urlencode($product["merchant"])."', '".urlencode($product["name"])."');return false;\"";
return $href;
}
and it seems to be working a treat.
I am trying to implement this code with the new version of GA(*), but with target=_blank.
However, I think it might be missing a comma because is not working as expected.
In tapestry_buyURL I have the following code:
$retval .= "' target='_BLANK";
$retval .= "' onclick=\"trackOutboundLink('".urlencode($product["buy_url"])."'); return false;\"";
return $retval;
(*)
https://support.google.com/analytics/answer/1136920?hl=en
Hi,
The onclick would need to go before the target (with intentionally missing closing single-quote) - have a go with:
$retval .= "' onclick=\"trackOutboundLink('".urlencode($product["buy_url"])."'); return false;\"";
$retval .= "' target='_BLANK";
return $retval;
Cheers,
David.
--
PriceTapestry.com
I get something like that
<a class="button tiny radius success" href="/jump.php?id=327527" onclick="trackOutboundLink('http://[...].html'); return false;" '="" target="_BLANK">Buy</a>
What is that '=""?
Hi,
What's happening is your template is using double-quoted attributes rather than single quotes, so this just needs to be mirrored in the code - have a go with;
$retval = $config_baseHREF."jump.php?id=".$product["id"];
$retval .= "\" onclick=\" trackOutboundLink('".urlencode($product["buy_url"])."');return false;\"";
$retval .= " target=\"_BLANK";
Cheers,
David.
--
PriceTapestry.com
Hi Adrian,
That should be straight forward to implement, most easily as a "hack" into the function that generates a Buy URL throughout the site. This can be done by returning a string that returns the Buy URL, a closing apostrophe, and then the Google Analytics JavaScript WITHOUT the closing apostrophe...
In includes/tapestry.php look for the following function;
function tapestry_buyURL($product)
{
global $config_baseHREF;
global $config_useTracking;
if ($config_useTracking)
{
return $config_baseHREF."jump.php?id=".$product["id"];
}
else
{
return $product["buy_url"];
}
}
...and REPLACE this with:
function tapestry_buyURL($product)
{
global $config_baseHREF;
global $config_useTracking;
if ($config_useTracking)
{
$href = $config_baseHREF."jump.php?id=".$product["id"];
}
else
{
$href = $product["buy_url"];
}
$href .= "' onClick='javascript: pageTracker._trackPageview(\"/outgoing/".$product["merchant"]."\");";
return $href;
}
That would give you a "virtual" directory structure as Google recommends of
/outgoing/Merchant Name
Cheers,
David.