Setup a custom field for each value you want to pass, then pop this into functions.php:
add_filter( 'salesforce_w2l_field_value', 'salesforce_w2l_field_value_ga_example', 10, 3 );
function salesforce_w2l_field_value_ga_example( $val, $field, $form ){
// Target a specific field on all forms
if( $field == 'YOUR_SALESFORCE_CUSTOM_FILED_FOR_SOURCE' )
$val = $_GET['source'];
if( $field == 'YOUR_SALESFORCE_CUSTOM_FILED_FOR_MEDIUM' )
$val = $_GET['medium'];
if( $field == 'YOUR_SALESFORCE_CUSTOM_FILED_FOR_CAMPAIGN' )
$val = $_GET['campaign'];
return $val;
}
Thread Starter
colum
(@colum)
Thanks Nick, seems simple enough. I read an article on how to pass information back from Salesforce to GA which would be amazing do you know if this is possible? Your plugin is excellent and I appreciate your assistance.
Articles I was referring to:
https://www.e-nor.com/blog/google-analytics/integrate-salesforce-and-google-analytics
https://www.e-nor.com/blog/google-analytics/the-ultimate-guide-to-universal-analytics-integration-with-salesforce
Thread Starter
colum
(@colum)
Hi Nick, I know its not part of your plugin but would be great to know if this is possible.
Thanks again for your help!
Definitely possible — just use the names/ids generated by the plugin in the JS code in that article.
Thread Starter
colum
(@colum)
Thanks Nick, I have set up the fields in SF and added the code above to the functions.php can you explain what I do with this part of the code?
‘salesforce_w2l_field_value_ga_example’, 10, 3 );
Thanks!
Thread Starter
colum
(@colum)
Do I have to add hidden fields in the form also?
Thanks
Yes you need some hidden fields to hold the data. Only defined fields get sent to SF.
Thread Starter
colum
(@colum)
Hi Nick,
Sorry to keep bugging you, I have added the fields into the form and added the fields into salesforce then I pasted the code you gave me above but something is missing as the values are not carrying through.
Any ideas what I might be doing wrong?
Thanks,
Colum
It’s hard to troubleshoot code I can’t see, and we’re beyond the scope of “free” support here.
If you’d like to hire me to help you out:
http://cimbura.com/tech/contact-us/project-request-website/
Thread Starter
colum
(@colum)
Thanks Mike – good to know, I will keep that in mind.
Thread Starter
colum
(@colum)
Hi Mike can you let me know how much it would cost to hire you to set up the system (I might not be using your plugin) as outlined here: https://www.e-nor.com/blog/google-analytics/the-ultimate-guide-to-universal-analytics-integration-with-salesforce#comment-120791
Let me know your thoughts.
Thanks
I received your premium support request, going to close out this thread and respond there.