Skip to content

Instantly share code, notes, and snippets.

@Daymannovaes
Created April 16, 2018 18:34
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Daymannovaes/0e23f5056a707189883929350e6c7149 to your computer and use it in GitHub Desktop.
Save Daymannovaes/0e23f5056a707189883929350e6c7149 to your computer and use it in GitHub Desktop.
/*
go to Promoter.io, go to a campaign and use the filter to search the time range that you want
Go to chrome dev tools and search for the url like:
https://app.promoter.io/org/YOUR_ORG_ID/campaign/YOUR_CAMP_ID/report/?start_date=2017%2F04%2F15&end_date=2018%2F03%2F28&method_name=load_es_nps_graph
be aware of the method name: load_es_nps_graph.
--
*/
// then copy the response, and parse it to object (just replace \" to " and remove the first and the last "),
// then move it to a variable named `nps`
// then
// csv by week
nps.nps_by_date.map(n => n.key_as_string + '\t' + n['nps_metrics.value.nps']).join('\n')
// ---
// csv by month
_.chain(nps.nps_by_date)
.map(n => Object.assign(n, { date: new Date(n.key_as_string) }))
.groupBy(n => n.date.getFullYear() + '-' + (n.date.getMonth()+1))
.mapValues(values => _.chain(values).map('nps_metrics.value.nps').mean().value())
.map((v, k) => k + '-15\t' + v)
.join('\n')
.value()
// then copy the results in https://plot.ly/create/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment