Viewing 2 replies - 1 through 2 (of 2 total)
  • Thread Starter Exponential

    (@exponential)

    I think the issue I am facing is being able to run this script within the form to get the GCLID cookie and then pass it to CF7 via a dynamic hidden field:

    <script>
            window.onload = function getGclid() {
                 document.getElementById("xxxx").value = (name = new
            RegExp('(?:^|;\\s*)gclid=([^;]*)').exec(document.cookie)) ?
            name.split(",")[1] : ""; }
            </script>

    xxxx = form field ID (for example “gclid_field”)

    Thread Starter Exponential

    (@exponential)

    For anyone wondering how to do this I think I have resolved the issue. Thanks to the help from https://www.sean-barton.co.uk/2014/04/contact-form-7-place-post-server-cookie-session-variables-fields/#.VkstpXbhCes

    function sb_cf7_cookie($atts){
        extract(shortcode_atts(array(
            'key' => -1,
        ), $atts));
    
        if($key == -1) return '';
        $val = '';
    
        if( isset( $_COOKIE[$key] ) ){
            $val = $_COOKIE[$key];
        }
    
        return $val;
    }
    add_shortcode('SB_CF7_COOKIE', 'sb_cf7_cookie');

    Once this has been added to functions.php you can call it using dyanmic text extension, as followed:

    [dynamichidden gclid_field "SB_CF7_COOKIE key='__utmz'"]

    I hope this helps others!

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Importing AdWords Conversions from Salesforce.com via CF7 & GCLID value’ is closed to new replies.