Hi GF team,
I want to migrate my WPCF7 forms to GF but I need some help with the tracking. On WPCF7 I have a function that when someone lands on the website with this parameter on the URL "myweb.com/?promo=mypromo", the it saves the "mypromo" as cookie for a 6 months period and if anyone contacts me, the "mypromo" comes attached.
Question is, how to do this with GF. I am using GF integration with salesforce, all working smoothly btw, just this promocode thing not at all. I just don't know how to set a new variable in GF fields with the dynamic promocode call I need.
This is the function I am using with WPCF7:
<?php
function tracking_cookie(){
if (!isset($_COOKIE['RD7cViG1mO6y'])) {
setcookie('RD7cViG1mO6y',base64_encode($_GET['promo']), strtotime('+6 month'), '/', 'myweb.com'); //Tracks Promo code
if (!isset($_COOKIE['qsJKX2zx3Le1'])) {
setcookie('qsJKX2zx3Le1',base64_encode($_SERVER['HTTP_REFERER']),strtotime('+6 month'), '/', 'myweb.com');
} //Tracks First Referrer to the website
}
}
add_action('init','tracking_cookie',0);
wpcf7_add_shortcode( 'tracker', 'wpcf7_tracker_shortcode', true );
function wpcf7_tracker_shortcode( $tag ) {
global $wpcf7_contact_form;
if ( ! is_array( $tag ) )
return '';
$name = $tag['name'];
if (!isset($_COOKIE['RD7cViG1mO6y'])) {
$tracker_code=$_GET['promo'];
} else {
$tracker_code=base64_decode($_COOKIE['RD7cViG1mO6y']);
}
$html = $html.'<input type="hidden" name="'.$name.'" value="'.$tracker_code.'" />';
return $html;
}
wpcf7_add_shortcode( 'referrer', 'wpcf7_referrer_shortcode', true );
function wpcf7_referrer_shortcode( $tag ) {
global $wpcf7_contact_form;
if ( ! is_array( $tag ) )
return '';
$name = $tag['name'];
if (!isset($_COOKIE['qsJKX2zx3Le1'])) {
$referrer=$_SERVER['HTTP_REFERER'];
} else {
$referrer=base64_decode($_COOKIE['qsJKX2zx3Le1']);
}
$html = $html.'<input type="hidden" name="'.$name.'" value="'.$referrer.'" />';
return $html;
}
?>
than I set [promo_code] and [referrer_link] in WPCF7 mail and this is how I have been using.
Can someone help me making this work on a GF hidden promocode field? (btw my salesforce promocode parameter is "Promo_Code__c").
Appreciate.
Hugo