Publishing Salesforce Analytics to Public Sites

Get going in just few minutes!

Arun V
Salesforce Analytics
3 min readJul 4, 2014

--

In this blog post we will explore how easy it is to publish to your favorite metrics to a public site which could either be your internal portal/intranet or even a public facing website using the Analytics API.

Please be careful with your data!

Here we are surfacing Salesforce data outside of the standard access model, so make sure to first test this out with a Developer org/Test data. When deploying “real” data, make sure the app is secured.

Live Demo: http://bit.ly/TIwrn3

Source Code: https://github.com/arun-sfdc/Analytics-API/tree/master/PublicDashboard

Step1: Identify your report and protect it

The first is to identify a report that is aggregating your key metrics. Since this is going to be broardcast to a broader audience, make sure that it is in a read-only folder and surfaces only the right metrics. In my Node.js app, I use the awesome JSForce library to connect to Salesforce and the Analytics API. For simplicity purposes, I use a username/password based login but more advanced and secure methods that should be considered for a production deployment.

Step2: Launching the Demo App

There are numerous deployment options when it comes to Node.js — local workstation, on-premise service or on the cloud. Our very own Heroku is one of the most popular deployment options you might want to consider. Docker is a new open source tool that make the entire deployment process hassle-free . I wanted to try it out with a test application, so I have bundled this as a docker container here: https://registry.hub.docker.com/u/dockerhubtrial/analyticsapi/

Option a: Private Deploy locally with NodeJS

Here are the steps if you are using Mac or Linux:

  1. Download and install — git, nodejs and npm
  2. Make a new directory and open it — mkdir dev2 and cd dev2
  3. Get the code — git clone https://github.com/arun-sfdc/Analytics-API
  4. Open source directory — cd Analytics-API/PublicDashboard/src
  5. Download dependencies — npm install
  6. Move one level up in directory — cd ..
  7. Start the App — node src/index.js
  8. Showtime! Point your browser to http://127.0.0.1:8080

Option b: Public Deploy with Docker container

If you have a Docker VM locally or an account with a Docker hosting platform feel free to skip the first step. Here’s are the steps to try it out, make sure you are using your demo data from a test login since this will be a public site:

  1. Signup for a account at a hosting site like https://www.tutum.co/ (They have a free trial going on now).
  2. Launch new application -> Public Images
  3. Search “analyticsapi” and select this “dockerhubtrial/analyticsapi”
  4. Go to Environment variables and add the following: SFDC_USERNAME, SFDC_PASSWORD, SFDC_URL, SFDC_REPORTID
  5. REMEMBER TO USE YOUR TEST LOGIN WITH FAKE DATA.
  6. Hit Launch, wait for the app to start.
  7. Click on container name “analyticsapi”
  8. Click on instance name “analyticsapi-1”
  9. Click on URL — looks like http://analyticsapi-1-tutum-trial2.delta.tutum.io:49165/

That’s it, in under 5 minutes you have hosted your Salesforce Analytics into a Public Site!

--

--