Using CBSaleTracker With WordPress Blogs
Track affiliate sales from headers, sidebars - even blog posts & pages!
Advanced Topic! Every Wordpress them is different, results may vary.
You must have some comfort level with WP themes and PHP to utilize (or hire someone).
Please read this ENTIRE PAGE before making any changes to your blog!
Tracking Sales From Headers and Sidebars
Using CBSaleTracker to track your sales from ads or other methods inside of a header, footer or sidebar is probably the simplest usage inside of a WordPress blog setting.
I repeat here: Every theme is different. With that said, here are some instructions for implementing CBSaleTracker in your WordPress blog and tracking your sales.
If you find that code in a widget or somewhere else does not work, you may need the "exec-php" plugin. More on that in the section about using CBSaleTracker in a blog post.
- We need to insert a statement into the header.php that will activate the CBSaleTracker code.
This is done in wp-admin under
"Appearance | Editor".
This code MUST be placed at the VERY TOP, before ANYTHING else!
Here is a tricky part. Sometimes it seems you have to use the FULL path for your site - as the SERVER sees it, not the user. For instance, with hostgator, it might be:<?php
if (!isset($_COOKIE['cbst'])) {
require_once("/includes/createtid.php");
setcookie("cbst", $cbtrack, time()+90000, "/");
$_COOKIE['cbst']=$cbtrack;
}
?>
/home/master_site_directory/public_html/site_directory + /includes/createtid.php - Now you can insert the same type of code as you would anywhere else on a webpage:
An example might look like this:<a href="http://{link}{tracking prefix}<?php echo $_COOKIE['cbst']; ?>">Anchor Text</a>Where link = 'y38xke8lzx.hop.clickbank.net/' and tracking prefix = '?tid='
<a href="http://y38xke8lzx.hop.clickbank.net/?tid=<?php echo $_COOKIE['cbst']; ?>">
Tracking Sales From WordPress Blog Posts
When you want to use CBSaleTracker to provide sales tracking information in an actual blog post or blog page, you must insert the code in the header as above first.
Then, you will have to add a plugin so that the php code in the post gets evaluated as code and not converted to text. I have used the exec-php plugin for this.
Exec-php will highly recommend that you turn off the WYSIWYG editor altogether - some of you may not like this, but there is nothing I or anyone else can do about it. If you want to execute code in a post, it must be done. I have experimented with other ideas to avoid this, but so far they have not worked.
The exec-php plugin has extensive installation instructions. From what I can tell, though, none of it really applies if you login to your blog administration panel as Admin. Only if you have users with assigned roles does it seem to apply.
So, install the plugin, activate it, turn off the WYSIWYG editor for you user (under Users | Your Profile there is a check box at the top labeled "Disable the visual editor when writing" under "Visual Editor"), and you are ready to go.
You can then add the same code shown above for headers & sidebars into a link in a post.
General Notes:
- Always make a backup of your code before making any modifications!
- You can name the cookie whatever you want, it does not have to be 'cbst'.
- You can use another variable other than $cbtrack if you want, especially if you are not using ClickBank. You can use $tid and not have to include the {tracking prefix} when you build your link. See the list of variables on the Testing Page.
- The '90000' number in the example above is a 25 hour cookie, in seconds (25 x 60 x 60). I am told you should never go less than that since some browser / web server combinations do not correctly adjust for time zone differentials. You can make it longer if you want, nothing magical about 90000 - just a suggested minimum.
- Cookies are NOT perfect, users can block them; but that's not a new problem to affiliate marketers!
Questions?
That's what the Support Forum is for!
Be advised, though, themes can vary and I am not going to be an expert on every one; but I will help where I can.