A lightweight, configurable Net Promoter Score (NPS) built with Svelte that compiles to a single JavaScript. Data is sent to your own Google Analytics account.
<script>
window.simpleNpsConfig = {
gaId: "G-XXXXXXXXXX",
};
</script>
<script src="https://cdn.jsdeliver.net/npm/[email protected]/dist/simple-nps.js">
Here are the default options, all overridable.
<script>
window.simpleNpsConfig = {
gaId: "G-XXXXXXXXXX",
i18n: {
en: {
intro: "How likely are you to recommend us?",
notLikely: "Not at all likely",
extremelyLikely: "Extremely likely",
submitBtn: "Submit",
thankYou: "Thank you for your feedback!",
followUp: "Could you tell us why?"
}
},
language: "en",
theme: {
primaryColor: "#007bff",
backgroundColor: "#ffffff",
textColor: "#333333",
borderRadius: "8px"
},
showFollowUp: true
};
</script>
Add a custom entry point.
```html
<div id="simple-nps"></div>
The automatically tracks these GA4 events:
nps_score: When user submits rating (0-10)nps_feedback: When user submits follow-up textScores are automatically categorized:
nvm use
npm install
npm run dev
npm run build
This generates dist/simple-nps.iife.js - a single file ready for deployment.