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.

Pre-populate forms based on Hubspot cookie

  1. Thought I would post this as it was pretty simple and potentially useful to anybody else using Hubspot and Gravity Forms. This is an easy way to pre-populate Gravity Forms with Hubspot data based on the user's Hubspot cookie.

    $cookie = $_COOKIE["hubspotutk"];
    
    $url = "http://api.hubapi.com/contacts/v1/contact/utk/".$cookie."/profile?hapikey=YOUR_HUBSPOT_API_KEY";
    	$data = file_get_contents($url);
    	$data = json_decode($data);
    	global $firstname;
    
    	$firstname = $data->properties->firstname->value;
    
    add_filter('gform_field_value_fname', 'fname_population_function');
    function fname_population_function($value){
    
    	global $firstname;
    	return $firstname;
    }
    Posted 6 years ago on Wednesday December 5, 2012 | Permalink
  2. David Peralty
    Administrator

    Thanks for posting this. I hope someone finds it helpful. You can use cookies set from nearly anything to help pre-populate forms as long as you know the data stored in that cookie.

    Posted 6 years ago on Wednesday December 5, 2012 | Permalink