I need to hand code an affiliate link (we do not want to use an existing plugin). I do not do a lot of coding, so bear with me.
It seems so simple I have a link: http://www.domain.com/?code=8765
Then I want to grab that code number and put it in a cookie. That way if a lead form goes in it can be passed through the API to SalesForce. Can anyone tell me why this isn't working? If the id variable is set to a string it works fine.
Does this even make sense to accomplish this using this method?
add_action( 'init', 'set_agent_cookie' );
function set_agent_cookie() {
$name = 'agent';
$id = $_GET['code'];
setcookie( $name, $id, time() + 3600, "/", COOKIE_DOMAIN );
}