[thelist] PHP - Making All Links Unique (even to same page)

Stephen Rider evolt_org at striderweb.com
Wed Jan 16 09:04:22 CST 2008


On Jan 15, 2008, Mark MacInnes wrote:

> My development team has developed our own CMS over the past year or  
> so.
> We've been asked by the Internet Marketing guys this morning to  
> make every
> single link on a page unique, even if they're going to the same  
> page, for
> tracking in Google Analytics etc. I'm not looking for code or  
> anything, just
> wondering what ideas people think are the best.
>
> So far, this is the only idea I've come up with:
> - When a page is created, append '_nav' to menu links,  
> '_bc#LinkNo#' to body
> content links (whereby #LinkNo# would be replaced by a unique  
> number for the
> link).
>
> But I feel a little uneasy with it as it would make the links a  
> little messy
> - we use URL Rewriting to try to make friendly links, and now we  
> might be
> chucking in some extra characters for no benefit to user or search  
> engine.

As you're using a CMS, you're clearly got programmatic control (e.g.  
PHP) in your pages.

I would give every link on the site a unique ID attribute.  Then I  
would use normal links, but also for any internal links also pass the  
ID of the followed link as a parameter -- e.g. example.com/about.php? 
src=link12345

Then drop a bit of code in your header template that tracks incoming  
links based on that passed id.

You could even do something like this for outgoing links -- passing  
all outgoing links through a forwarder script that tracks the link  
clicked before passing the reader along.  I've seen this done without  
breaking the Back button, but I don't know how, specifically....

Hope that helps. :)

Regards,
Stephen


-- 
Stephen Rider
<http://striderweb.com/>





More information about the thelist mailing list