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.

Google Analytics & Gravity Forms

  1. I have been able to successfuly collect information from my urls (google url builder) into my forms via the prepopulate fields options. This has been great!

    I have seen people post regarding collecting information from the actual Google Adwords Cookie. I am hoping to collect from this as the information will not be lost as the user navigates the site. (I know this seems unnecessary but my ultimate goal is getting the information into SalesForce which thanks to Web-To-Lead I have already figured out).

    [php]
    //DEFINE COOKIE DOMAIN, ALLOWS SCRIPT TO BE USED ACROSS MULTIPLE DOMAINS
    $domain = $_SERVER['SERVER_NAME'];
    $domain = "." . ltrim($domain,"www.");
    
    // SET COOKIES FROM GOOLGE-ANALYTICS COOKIE
    $info = $_COOKIE['__utmz'];
    // Get rid of id stuff
    $holder = split("u", $info, 2);
    $string = "u" . $holder[1];
    // Parse String
    $ga_vars = split("\|", $string);
    foreach ($ga_vars as $var) {
    list($key,$value) = split("=",$var);
    if ($key == "utmcmd") { setcookie("Medium", $value, time()+100000000, "/", $domain); $medium = $value; }
    if ($key == "utmctr") { setcookie("Keywords", $value, time()+100000000, "/", $domain); $keywords = $value; }
    if ($key == "utmcsr") { setcookie("GAsource", $value, time()+100000000, "/", $domain); $gasource = $value; }
    }
    
    // SET REFERRING URL
    if (!isset($_COOKIE['Referer'])) {
    setcookie("Referer", $_SERVER['HTTP_REFERER'], time()+10000000, "/", $domain);
    $referurl = $_SERVER['HTTP_REFERER'];
    } else { $referurl = $_COOKIE['Referer']; }
    
    // SET FORM_URL VALUE
    $formurl = "http://".$_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI'];
    
    // SET LANDING PAGE
    if (!isset($_COOKIE['LandingPage'])) {
    setcookie("LandingPage", "http://".$_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI'], time()+10000000, "/", $domain);
    $landingpage = "http://".$_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI'];
    } else { $landingpage = $_COOKIE['LandingPage']; }

    Running this script I should be able to set the parameters of the cookie and call it into my form. Since the name field of the form elements can not be changes I am of the impression that I am going to need to change the names in the script to reflect the generated code from gravity forms to something like field_22.

    Like many of the users of gravity forms I am not a technical user. I have spent alot of time researching a solution and have tried 3rd party gravity form plugins to try to solve this problem. I have read many pages of code and scripts but my simple mind can not get paste the copy, paste, and pray mentality.

    If the admins are not able to address this questions I am also willing to pay for a solution (allowing my site to set a cookie, the information to be pulled into gravity forms, and sent with the rest of my data to salesforce.

    Thank You!

    Posted 11 years ago on Monday October 1, 2012 | Permalink
  2. I need a little more background information to try and understand what you are doing. Sounds like you want to get the information from the Google Adwords cookie and set those values in your own cookie? Is that accurate? If so, and this is the code to do it, when does this code run?

    Assuming this code is running at the correct time, are you trying to dynamically populate certain form fields to the values you retrieved from the Google Adwords cookie?

    Posted 11 years ago on Tuesday October 2, 2012 | Permalink

This topic has been resolved and has been closed to new replies.