<?xml version="1.0" encoding="iso-8859-1"?> 
<rdf:RDF
	xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" 
	xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#"
	xmlns:dc="http://purl.org/dc/elements/1.1/" 
	xmlns:dcterms="http://purl.org/dc/terms/" 
	xmlns:admin="http://webns.net/mvcb/"
	xmlns:thr="http://purl.org/rss/1.0/modules/threading/"
	xmlns:pb="http://www.ideaspace.net/users/wkearney/schema/postback/" 
	xmlns:trackback="http://madskills.com/public/xml/rss/module/trackback/" 
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	xmlns:mt="http://movabletype.org/"
	xmlns:foaf="http://xmlns.com/foaf/0.1/" 
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:html="http://www.w3.org/TR/REC-html40/"
	xmlns="http://purl.org/rss/1.0/"
> 

<rdf:Description rdf:about="http://www.ideaspace.net/users/wkearney/archives/entries/000238.html"> 
	<title>Capturing links</title>
	<link>http://www.ideaspace.net/users/wkearney/archives/entries/000238.html</link>
	<description>Let&apos;s say you want to know if people are using the links on your page.  If you use plain HREF links you can&apos;t easily track them.  What you have to do is capture the links.  Here&apos;s how to do it...</description> 

	<dc:creator>wkearney</dc:creator> 
	<dc:date>2003-04-08T12:59:42-05:00</dc:date> 
	<dc:identifier>http://www.ideaspace.net/users/wkearney/archives/entries/000238.html</dc:identifier>
	<dc:language>en-us</dc:language>

	 
	<dc:subject>Hacks</dc:subject>

	

	

	
	
	
	<dcterms:abstract>Let&apos;s say you want to know if people are using the links on your page.  If you use plain HREF links you can&apos;t easily track them.  What you have to do is capture the links.  Here&apos;s how to do it...</dcterms:abstract> 
	<dcterms:created>2003-04-08T12:59:42-05:00</dcterms:created> 
	<dcterms:isPartOf rdf:resource="http://www.ideaspace.net/users/wkearney/" /> 

	<mt:body><![CDATA[<p>Let's say you want to know if people are using the links on your page.  If you use plain HREF links you can't easily track them.  What you have to do is capture the links.  </p>

<p>Doing this, without a lot of manual editing, is often a pain.  There's one way to do it without a lot of data entry hassles.  Use an MT plugin to rewrite the links using a macro.   Here's how...</p>]]></mt:body>
	<mt:excerpt>Let&apos;s say you want to know if people are using the links on your page.  If you use plain HREF links you can&apos;t easily track them.  What you have to do is capture the links.  Here&apos;s how to do it...</mt:excerpt> 
	<mt:more><![CDATA[<p>This is a multi-step process.  Proceed at your own risk.  You'll have to know a bit about creating and editing MovableType templates.  You'll also have to know how to install and manage various sorts of add-ons.  This is not a step-by-step tutorial.  If you hose your MT site don't come cryin' to me.</p>

<p>First get a click-trough tracking tool.  There are several available, here's <a href="http://www.devscripts.com/category.php?stId=231">few for PHP</a>.  Install it and note what URL it uses to handle the redirects.</p>

<p>Then go get Brad Choate's <a href="http://www.bradchoate.com/past/mtmacros.php">MTMacro</a> plugin and install it.  Once it's installed, create a new index template and copy your current home page index template into it.  This to give you a good starting point.  Be sure to instruct the template to save it into some temporary filename.  Once you're sure this works you'll want to rearrange this into the proper place.</p>

<p>Now I edited my template such that it contains this text at the start: <blockquote>&lt;MTMacroDefine name="prefix" string='href="http://'><br />
href=http://example.com/cgi-bin/click/click.php?http://<br />
&lt;/MTMacroDefine></blockquote></p>

<p>This is a macro definition that tells the rebuilding process to look for the 'http://' prefix and to replace it with your customer click-through URL prefix.  </p>

<p>Now find the places you'd like to have URLs changed to use the macro.  I put a wrapper around &lt;$MTEntryBody$> like so:<blockquote>&lt;MTMacroApply macro="prefix"><br />
&lt;$MTEntryBody process_tags="1"$><br />
&lt;/MTMacroApply></blockquote></p>

<p>The use of the macro here tells MT to dig into the entry body, find anything starting with <em>href="http://</em> and replace it with my link tracker.  It's important to limit how much the macro searches.  By wrapping only the EntryBody section it doesn't disturb the rest of my site's links.</p>

<p>Here's my <a href="http://www.ideaspace.net/users/wkearney/">regular home page</a> and here's one with <a href="http://www.ideaspace.net/users/wkearney/indexc.html">click tracking</a> turned on.  The user experience for them is exactly the same.  They click a link and are taken to a web page.  What's happening with tracked links is a database is updated noting the use of the link.  I can use other tools to check the database and see what links are being used.</p>

<p>Technically, yes, you can glean this same information by reading the webserver log files.  However, if you want to perhaps <i>do something</i> different based on how links are used this is an opptune way to do it. </p>

<p>Tracked links like this aren't good for bookmarks.  The URLs get long and if your link tracker is broken users might get confused.  Once they get to the distant site everything's fine.  It's only a problem if they make a bookmark based on the link directly from your site. </p>

<p>Adding link tracking is pretty easy.  Whether or not it's a good idea is up to you. </p>]]></mt:more>
	<mt:keywords></mt:keywords> 
	<mt:entryID>238</mt:entryID>

	<mt:entryPrev>237</mt:entryPrev>
	<mt:entryNext>239</mt:entryNext>

	<html:link rel="prev" type="application/xml" href="http://www.ideaspace.net/users/wkearney/archives/entries/000237.html.xml" title="Spammer loses in hearing" />
	<html:link rel="next" type="application/xml" href="http://www.ideaspace.net/users/wkearney/archives/entries/000239.html.xml" title="Attending FOSE?" />
	
	<mt:author>wkearney</mt:author> 
	<mt:authorNickname>Bill Kearney</mt:authorNickname> 
	<mt:authorEmail>wkearney@ideaspace.net</mt:authorEmail>
	<mt:authorURL rdf:resource="http://www.ideaspace.net/users/wkearney" /> 
	
	<foaf:name>wkearney</foaf:name> 
	<foaf:mbox rdf:resource="mailto:wkearney@ideaspace.net" /> 
	<foaf:nick>Bill Kearney</foaf:nick> 
	<foaf:homepage rdf:resource="http://www.ideaspace.net/users/wkearney" />
	
	<rdfs:seeAlso rdf:resource="http://www.ideaspace.net/users/wkearney/xml/index.rdf" />
	<admin:generatorAgent rdf:resource="http://www.movabletype.org/?v=2.64" /> 
</rdf:Description>
</rdf:RDF>