URL Parameter help
-
Hi, I know that I can use filters for this, but I’m not sure just how.
I would like to capture URL parameters in the form. I use this for PPC tracking form entires.
An example URL would look like this:
https://www.example.com?c=123&kw=string
the ‘c’ and ‘kw’ fields are present in SF, and I can reference them either by id (00N20000009J06l) or API name (Campaign_ID__c)
So my question is if I create these above as hidden fields in the form, what syntax do I need for the filter? At the moment, I think I need to add a little more than just the below as otherwise, the filter doesn’t know which parameter is which.
So I need to say that if parameter ‘c’ exists in the URL it is field campaign_ID__c
<?php /* How to use: 1. Create a custom URL field at SalesForce 2. Replace URL_CUSTOM_FIELD_NAME below with the name of the custom field you setup in SalesForce, it will be something like EmbedUrl__c 3. Add a hidden field to each form with the same field name (e.g. "EmbedUrl__c"). 4. Make sure the hidden field is enabled (or it won’t be output with the form/get filled/be sent to SF). 5. Profit */ add_filter( 'salesforce_w2l_field_value', 'salesforce_w2l_field_c', 10, 3 ); function salesforce_w2l_field_c( $val, $field, $form ){ // Target a specific field on all forms if( $field == 'CAMPAIGN_ID__c' ) $val = esc_url("https://".$_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI']); return $val; }
Should the above work?
- The topic ‘URL Parameter help’ is closed to new replies.