## Introduction
In product management and growth teams, understanding how users adopt various features is crucial for prioritization, iterating on existing functionality, and driving product-market fit. However, manually aggregating usage data and generating adoption scores per feature is tedious and error-prone, especially as product usage grows across thousands or millions of users.
Automating the calculation of adoption scores based on raw usage data allows product teams to gain near real-time insights. This blog post provides a detailed, step-by-step guide to building an automated workflow using n8n — an open-source, extensible workflow automation tool — to calculate adoption scores per feature. This setup benefits product managers, data analysts, and growth teams who need reliable, scalable feature usage analytics without heavy engineering effort.
—
## What Problem This Automation Solves
**Problem:**
Product teams want to understand the popularity and adoption of individual product features, typically by counting the number of unique users interacting with each feature over time, then normalizing this to generate an adoption score. Without automation, this involves manual data exports, complicated SQL queries, or expensive analytics tools.
**Who benefits:**
– Product managers looking to prioritize features
– Growth and marketing teams measuring engagement
– Data teams who want a lightweight automation pipeline
—
## Tools and Services Integrated
– **n8n**: The automation platform to build and orchestrate the workflow.
– **PostgreSQL or MySQL**: Database where raw user interaction logs are stored.
– **Google Sheets**: Output destination for adoption scores, easy to share internally.
– **Slack**: Optional channel notification on score updates.
Note: This workflow can be adapted to other databases or output systems like a BI tool or internal dashboard.
—
## Overview of the Workflow
1. **Trigger**: Scheduled trigger runs daily to update adoption scores.
2. **Query Usage Data**: Pull raw user event logs from the database filtered by date range.
3. **Calculate Unique Users per Feature**: Process the query results to count distinct users per feature.
4. **Calculate Adoption Score**: Normalize the counts against total active users or last period’s totals.
5. **Write Results to Google Sheets**: Append or overwrite the scores for easy access.
6. **Notify via Slack**: Optional summary notification sent to a Slack channel.
—
## Step-By-Step Technical Tutorial
### Prerequisites
– n8n installed locally or hosted (cloud, Docker, or n8n.cloud).
– Access to the product’s event logs in a SQL database.
– Google Sheets API credentials.
– Slack workspace and bot credentials (optional).
### Step 1: Create the Scheduled Trigger in n8n
– Drag the **Cron** node onto your canvas.
– Configure to run **once daily** at your desired time (e.g., 2 AM) to minimize impact on database and internal users.
### Step 2: Query Raw Usage Data
– Add a **PostgreSQL** (or MySQL) node connected to the Cron node.
– Configure the DB node with your credentials.
– Write SQL query to extract user interactions in the past day or desired period:
“`sql
SELECT feature_name, user_id
FROM user_feature_events
WHERE event_timestamp >= NOW() – INTERVAL ‘1 day’
“`
– This assumes you have a table `user_feature_events` logging feature usage per user with timestamps.
### Step 3: Aggregate Unique Users Per Feature in n8n
– Add a **Function** node after the database node.
– Use JavaScript in the Function node to count unique user IDs per feature:
“`javascript
const results = {};
// data is array of records from DB
for (const item of items) {
const { feature_name, user_id } = item.json;
if (!results[feature_name]) {
results[feature_name] = new Set();
}
results[feature_name].add(user_id);
}
// Transform results to array of { feature_name, unique_users }
const output = [];
for (const [feature, users] of Object.entries(results)) {
output.push({ json: { feature_name: feature, unique_users: users.size } });
}
return output;
“`
This code deduplicates users per feature.
### Step 4: Calculate Adoption Scores
You can calculate adoption scores by normalizing unique users over total active users.
– Add another **Function** node after the aggregation node.
– For the example, let’s assume total active users fetched via SQL or configured statically (e.g., 10,000 users).
“`javascript
const totalActiveUsers = 10000; // Ideally, compute dynamically
return items.map(item => {
const adoptionScore = (item.json.unique_users / totalActiveUsers) * 100; // percentage
return { json: { …item.json, adoption_score: adoptionScore.toFixed(2) } };
});
“`
### Step 5: Write Results to Google Sheets
– Add a **Google Sheets** node to write or update a specific Sheet.
– Configure credentials and choose the spreadsheet and sheet name.
– Choose the operation type: ‘Append’ or ‘Update’.
– Map the fields:
– Feature Name → Column A
– Unique Users → Column B
– Adoption Score (%) → Column C
Make sure the Sheet has appropriate headers.
### Step 6: Notify via Slack (Optional)
– Add a **Slack** node connected to the Sheets node.
– Configure a webhook or bot token for your workspace/channel.
– Compose a message summarizing the top features by adoption score or any threshold.
Example message template:
“`
Daily Adoption Score Update:
{{ $json[“feature_name”] }}: {{ $json[“adoption_score”] }}%
“`
Use n8n’s workflow variables to build the message dynamically.
—
## Common Errors and Tips to Enhance Robustness
– **DB connectivity errors:** Ensure credentials, firewall rules, and network access are properly configured.
– **Data freshness:** Confirm event timestamps are timezone consistent and use UTC to avoid confusion.
– **Large datasets:** If usage logs are very large, consider incremental updates (e.g., using last processed timestamp) or pre-aggregated tables for efficiency.
– **API rate limits:** Google Sheets and Slack have quotas; batch updates or use delay nodes if running large-scale workflows.
– **Error handling:** Add error catch nodes in n8n to retry or alert on failures.
—
## How to Adapt or Scale This Workflow
– **Add more granular time windows:** Instead of daily, run hourly or weekly.
– **Support multiple product lines:** Filter or group by product, region, or user segment.
– **Integrate with BI tools:** Output JSON files or push data directly to dashboards.
– **Use Cache:** Store last run timestamp in a key-value store to fetch only incremental data, improving performance.
– **Trigger on events:** Rather than scheduled, trigger when data is updated using webhooks or database triggers.
—
## Summary
Automating adoption score calculation for product features frees product teams from manual data crunching and provides timely insights that drive informed decisions. Using n8n’s flexible nodes along with SQL databases, Google Sheets, and Slack integrations, you can build a scalable, maintainable automation pipeline that aggregates unique user counts per feature and computes normalized adoption scores. This guide walks you through creating this workflow end-to-end, complete with best practices and scalability tips.
**Bonus Tip:** To further enhance your workflow reliability, incorporate automated anomaly detection by comparing scores to historical averages and generate alerts when feature adoption drops unexpectedly.
—
By integrating automation into your data processes, your product team can continuously monitor and optimize feature engagement, thereby accelerating product success and customer satisfaction.