• Resolved gmull

    (@gmull)


    Can the Brilliant Web-to-Lead for Salesforce plugin support a script that pulls the url resulting from a google ad clickthrough into a hidden field of the landing page form for entry into a custom salesforce field?

Viewing 4 replies - 1 through 4 (of 4 total)
  • Plugin Author brilliantplugins

    (@brilliantplugins)

    You can create a hidden field that is mapped to a Saleforce custom field, then fill that with the gclid via JS using this approach.

    Note that your field name (in the DOM) will likely be sf_gclid__c due to prefacing by the plugin and the suffix added by Salesforce. It may vary based on what you named it in Salesforce.

    e.g. Assuming the field is named gclid in SF which makes the API name gclid__c:

    window.onload = function() {
            document.getElementById('sf_gclid__c').value = readCookie('gclid');
    }
    Thread Starter gmull

    (@gmull)

    Thanks. The custom gclid_C field was created and mapped in Salesforce and we created a new Brilliant form with the custom field set as “enabled” and the type value set to “hidden.” We added shortcode and the script to the page and the form does not appear to submit and does not post to salesforce.

    Separately, we have successfully been able to post the gclic id using native salesforce web-to-lead functionality based on the following script (posted below) but this means that we cannot leverage the Brilliant plugin capabilities. Appreciate any thoughts you can provide.

    <form action="https://webto.salesforce.com/servlet/servlet.WebToLead?encoding=UTF-8" method="POST"><script>
            window.onload = function getGclid() {
                 document.getElementById("XXXXXXXXXXXXXXX").value = (name = new
            RegExp('(?:^|;\\s*)gclid=([^;]*)').exec(document.cookie)) ?
            name.split(",")[1] : "";}
            </script>
    
    <input name="oid" type="hidden" value="XXXXXXXXXXXXXXX" />
    <input name="retURL" type="hidden" value="https://" />
    
    <label for="first_name">First Name</label><input id="first_name" maxlength="40" name="first_name" size="20" type="text" />
    
    <input id="XXXXXXXXXXXXXXX" name="XXXXXXXXXXXXXXX" type="hidden" />
    
    <input name="submit" type="submit" />
    
    </form><script type="text/javascript">
    function setCookie(name, value, days){
        var date = new Date();
        date.setTime(date.getTime() + (days*24*60*60*1000));
        var expires = "; expires=" + date.toGMTString();
        document.cookie = name + "=" + value + expires;
    }
    function getParam(p){
        var match = RegExp('[?&]' + p + '=([^&]*)').exec(window.location.search);
        return match && decodeURIComponent(match[1].replace(/\+/g, ' '));
    }
    var gclid = getParam('gclid');
    if(gclid){
        var gclsrc = getParam('gclsrc');
        if(!gclsrc || gclsrc.indexOf('aw') !== -1){
    	    setCookie('sf_gclid__c', gclid, 90);
    	}
    }
    </script>
    Thread Starter gmull

    (@gmull)

    Hi There – still have not been able to get this to work with the Brilliant form. Any thoughts?

    Plugin Author brilliantplugins

    (@brilliantplugins)

    It should be possible, but it’s difficult to troubleshoot something I can’t see.

    If it works with the Salesforce form, it should work with the plugin form. There’s nothing special about the plugin form (other than the auto prefixed field names).

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Support for Google Click ID (GCLID)’ is closed to new replies.