PLEASE NOTE: These forums are no longer utilized and are provided as an archive for informational purposes only. All support issues will be handled via email using our support ticket system. For more detailed information on this change, please see this blog post.

How to change/create new field variable?

  1. 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

    Posted 8 years ago on Tuesday April 10, 2012 | Permalink
  2. Hi Hugo,

    I do something similar. Did you get this resolved?

    Thanks,
    John

    Posted 7 years ago on Tuesday April 23, 2013 | Permalink
  3. David Peralty

    You would create a hidden field that would have the Allow this field to be populated dynamically checked off. Then you would use gform_pre_render to check for the cookie, grab the value and stuff it into your hidden field.

    http://www.gravityhelp.com/documentation/page/Gform_pre_render

    Posted 7 years ago on Wednesday April 24, 2013 | Permalink
  4. Thanks David...

    Posted 7 years ago on Wednesday April 24, 2013 | Permalink