A classic in B2B marketing: an end-to-end funnel that gives a complete overview of the cost-per-acquisition or even the return-on-investment. Given the fact that Salesforce is one of the most popular CRMs in the world, creating an end-to-end funnel analysis might require you to interact with Salesforce. Let’s do it in R.
The easiest way to get data out of Salesforce, whether classic or the Lightning platform, is via SOQL queries. SOQL is an acronym for Salesforce Object Query Language. It is a simplified structured query language. You can find some of the limitations in the documentation.
First, you can get authorized via OAuth using the sf_auth function. It will open a browser window where you can log into Salesforce. You can also login through your company’s my.tvh.com domain and via Single Sign-on.
For many, this will be the most important part of this blog post. If you receive an error in both your R console and your browser, you need to install the httpuv package, a building-block of the salesforcer package.
R: httpuv not installed, defaulting to out-of-band authentication
Querying data is straightforward if you know some SQL. In the following example, I query all email adresses from the Lead object. If you want to filter on a date, don’t forget to use the DAY_ONLY function.
df <- sf_query( soql = 'SELECT Email FROM Lead WHERE DAY_ONLY(CreatedDate) > 2020-09-01 NULLS FIRST' )