Add referral data into hidden form fields

Hi,
I want to add first refer, source etc to hidden form fields so I can connect this in the crm to individual submissions.
With the help of this great tutorial How To Add UTM And Referrer Information To Lead Forms? | Terminus Blog I get the cookies in the browser for par example:

_uc_referrer
_uc_last_referrer
_uc_visits
and the more usual suspects codes like:
_uc_utm_source
_uc_utm_campaign

In the tutorial there is an example how to get the data into mailchimp.
Anywone an idea how to get these cookie data it into grafity form hidden fields?
I found a clue here Enrich Form Submission Data with Google Tag Manager - Analytics Mania I can get the terminus first party cookie in the site. I can pick them up as variables in GTM, but need a clue how to get first party cookies into hidden fields OR get GTM varables into gravity hidden fields…

I found this https://docs.gravityforms.com/gform_field_value_parameter_name/#h-populate-from-a-cookie

add_filter( 'gform_field_value_utm_campaign', 'populate_utm_campaign' );
function populate_utm_campaign( $value ) {
   return $_COOKIE['utm_campaign'];
}

cookie name =_uc_referrer
form fiedl name = Initial REFERRER
And the parameter name for dynamicpupulate =_uc_referrer

What should the code be?

In the documentation example utm_campaign is the name of the parameter configured in the field and also the name of the cookie, you’re doing the same, using the cookie name as parameter name, so simply replace all occurrences of utm_campaign in the example with _uc_referrer

1 Like

Thank you. I got it working. But on Iphone its not working. I assume Safari blocks the cookie collection?
Anyway; is thee a comparable way to populate field from the DataLayer?