The article covers the basic setup of a custom tracking domain with cloaking.
Facebook Issues
My tests indicate that this approach gets around the current issue with pasting clkmg.com links on Facebook since Facebook does not appear to look past the custom tracking domain.
Before getting into the details let's consider the pros and cons of this approach.
Benefits Of Cloaked Custom Tracking Domains
- The link you use in email, blog posts, ads and facebook refer to a URL that can be related to your niche
- The user browser address bar shows the tracking domain URL
- When referring to the tracking domain in Facebook, Facebook does not inspect the content of the page so it does invalidate the link as the reference to clkmg.com is on the src of an iframe
Disadvantages Of Cloaked Custom Tracking Domains
- When entering a tracking domain URL link in Facebook no thumbnail image, title or description is displayed as this information only is available when the link resolved to a clkmg.com link
In this example I have customized Patrick's script by adding some lookup code to provide the Facebook information which removes the disadvantage cited above.
Custom Tracking Domain
Here are my steps to set up the domain genesisclub.reviews as a cloaked custom tracking domain.
-
Set Up The Custom Tracking Domain
-
The full instructions for setting up the domain are given in ClickMagick FAQ article number 61. Complete steps 1 through 6.
In Step 2 of the ClickMagick instructions, you are asked to click a link called Generate the custom files. Clicking this link generates a zip file to download. On the custom code generation page, make sure you remember to enable cloaking for the domain as shown in the screenshot below.
-
Create A Tracking Link
-
The link I am going to create is http://genesisclub.reviews/wordpress-training/
I set up the link on ClickMagick as usual and choose my newly created custom tracking domain.
-
Test The Link
-
First I do a basic test in the browser address bar and then I test the link on Facebook
Basic Test
Put the link in the browser in a window and verify the following:
- The browser URL remains unchanged
- The target page (link destination) appears as expected (it is framed)
Facebook Test
Go to your own Facebook page and create a status message with publish settings of Only Me and paste your tracked link. The link will be accepted (see below), however you do not get the Facebook image thumbnail, title and description.
Post the status (as Only Me) and check the link operates correctly.
-
Customize The Cloaking Script To Support Facebook Open Graph Tags
-
Two changes are required; one is a switch statement to define the Facebook tags for each link; the second is the code to write the Facebook tags in the HEAD section of the page. This makes them available to Facebook.
Here are the two code snippets; the first you need to customize for your own links; the second can be used verbatim.
Code Snippet For Facebook Tag Definition
[raw]
switch ($l) {
case 'wordpress-training':
$oga = 'article';
$ogu = 'http://genesisclub.reviews/wordpress-training/';
$ogt = 'Get Started With WordPress and Genesis The Right Way';
$ogd = 'Genesis Club Apprentice is a 16 week online video training course with monthly live webinars to help you on the path to being a Genesis super-user.';
$ogi = 'http://www.genesisclub.training/wp-content/uploads/wordpress-training.jpg';
break;
default: $oga = $ogu = $ogt = $ogd = $ogi = '';
}
[/raw]The values are are follows;
- oga - Open Graph Type - typically article or product
- ogu - URL that is being promoted - put your tracked link here
- ogt - Title - the title that appears benath your status message
- ogd - Description - excerpt that appears beneath the title
- ogi - Image - the image you are going to display on Facebook to attract attention to the message - choose a size of arround 484 by 253 pixels for maximum effect
Code Snippet For Facebook Tag Injection
Find the following section in the index.php file
[raw]
';
if ($cloak == "Y") {
echo '
}
[/raw]and replace it with the following code which creates a HEAD section in the page output with the Facebook tags for the chosen link
[raw]if ($cloak == "Y") {
', $url );
if (!empty($ogt)) print '';
if (!empty($ogt)) printf('<title>%1$s', $ogt);
if (!empty($ogt)) printf('', $ogt);
if (!empty($oga)) printf('', $oga);
if (!empty($ogd)) printf('', $ogd);
if (!empty($ogi)) printf('', $ogi);
if (!empty($ogu)) printf('', $ogu);
if (!empty($ogt)) print '';
printf( '
if (!empty($ogt)) print '