Dynamic Cross-Domain Canonical URL’s with PHP

Google announced support for specifying a canonical representation of content back in Feb of 2009. This was done in order to help webmasters avoid duplicate content in their sites by specifying the rel=”canonical” link element in the head section of duplicate pages. In December of 2009, Google announced the ability to implement the canonical tag cross-domain. This is particularly helpful for webmasters who have mulitple domain names pointing at the same content and cannot implement 301 redirects on their servers.

If you have a dynamic site, editing the head of each document individually is not possible. In thisĀ  situation you can utilize the Apache REQUEST_URI server variable in PHP to create the canonical link element dynamically. The example code is below:

<link rel="canonical" href="http://www.domain.com<?php echo htmlspecialchars($_SERVER['REQUEST_URI']) ?>" />

In this example, you would put the code snippet in the head area of your dynamic page(s) on your other domains ie. domain.net and domain.org. This tells the search engines that no matter what the path or page is on those domains, the canonical location of that page is located on domain.com.

Adwords Conversion Code in Vbulletin

I am working on reviving a semi-dead forum of mine and decided to give it a kick start with a small Google Adwords campaign. Before starting the campaign, I wanted to be sure I could track conversions, which in this case a conversion means a new member signing up. The forum is running on the popular Vbulletin forum software. I have never seen any documentation of where to place the conversion code in Vbulletin, so after some trial and error, I got it working. Here are 3 easy steps, with screen shots, to show you how to implement it on your own vbulletin forum.

Step 1. Grab your conversion code from Adwords.

Step 2. Go into the admin area of your Vbulletin installation and select “Search in Phrases”. Then enter the search term “Your registration is now complete”.

Step 3. Next you will see the phrase search results containing the search phrase we used. This is the snippet of code that is displayed when a user successfully completes a registration in Vbulletin. Edit these and add your Adwords Conversion code after the text and save. That’s it!