@mahe_pkm/buzl-capi 0.1.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/Buzl_GoogleAppsScript_Template.gs +948 -0
- package/CHANGELOG.md +83 -0
- package/LICENSE +21 -0
- package/README.md +253 -0
- package/assets/js/buzl-tracking.js +390 -0
- package/bin/cli.js +155 -0
- package/package.json +54 -0
- package/src/cli/terminal.js +388 -0
- package/src/core/injector.js +321 -0
- package/src/core/rollback.js +281 -0
- package/src/core/scanner.js +506 -0
- package/src/core/tester.js +357 -0
- package/src/gui/public/app.js +942 -0
- package/src/gui/public/index.html +634 -0
- package/src/gui/public/style.css +1130 -0
- package/src/gui/server.js +232 -0
- package/src/index.js +47 -0
- package/src/templates/GoogleAppsScript.gs +948 -0
- package/src/templates/buzl-tracking.js +475 -0
- package/src/templates/gtm-meta-snippets.js +149 -0
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
# Changelog
|
|
2
|
+
|
|
3
|
+
All notable changes to the **Buzl Tracker & Conversions API (CAPI)** project will be documented in this file.
|
|
4
|
+
|
|
5
|
+
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
|
|
6
|
+
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
|
7
|
+
|
|
8
|
+
---
|
|
9
|
+
|
|
10
|
+
## [0.1.2] - 2026-09-14
|
|
11
|
+
|
|
12
|
+
### Changed & Improved
|
|
13
|
+
- **100% Dynamic Test Lead Generation**:
|
|
14
|
+
- Removed all hardcoded mock client data (`9585950059`, `Sports Injury Rehabilitation`, `samya-sports-clinic`, `Bengaluru`, `Test Patient`).
|
|
15
|
+
- `tester.js`: `domain` dynamically resolves from `config.domain`, URL hostname, or folder name (`path.basename(rootDir)`).
|
|
16
|
+
- `tester.js`: `phone`, `service`, `location`, and `email` dynamically pull from detected website metadata and actual form fields with clean neutral fallbacks.
|
|
17
|
+
- `scanner.js`: Removed hardcoded `Bengaluru` fallback, dynamically extracts `detectedDomain` and `detectedService`.
|
|
18
|
+
- `app.js` & `index.html`: Web GUI test cards dynamically pre-fill phone, service, and location from live site scan results instead of static mock strings.
|
|
19
|
+
- `bin/cli.js`: CLI version output dynamically loads from `package.json`.
|
|
20
|
+
- **Enhanced Test Suite Resilience**:
|
|
21
|
+
- `multipage.test.js`: Added transient in-process HTTP mock server to guarantee 100% offline self-contained test execution.
|
|
22
|
+
- Added Test 13 in `injector.test.js` verifying dynamic test lead dispatch parameters.
|
|
23
|
+
|
|
24
|
+
---
|
|
25
|
+
|
|
26
|
+
## [1.0.0] - 2026-09-14
|
|
27
|
+
|
|
28
|
+
### Initial Release
|
|
29
|
+
|
|
30
|
+
#### ๐ Core Features & CLI Architecture
|
|
31
|
+
- **Interactive Terminal Wizard**: Guided CLI setup via `npx buzl-tracker` with input validation, intelligent defaults, and instant test verification.
|
|
32
|
+
- **Zero-Dependency Web GUI**: Embedded local dashboard on `http://localhost:3333` (`npx buzl-tracker --gui`) for visual configuration, live site state inspection, and per-form test dispatches.
|
|
33
|
+
- **Universal Multi-Page Scanner**:
|
|
34
|
+
- Automatically crawls directories at any depth.
|
|
35
|
+
- Automatically resolves relative asset paths (e.g. `assets/js/buzl-tracking.js`, `../assets/js/...`, `../../assets/js/...`) to ensure tracking scripts execute on every page.
|
|
36
|
+
- Groups forms into shared archetypes across multi-page sites.
|
|
37
|
+
- **Universal WhatsApp Auto-Fetch**:
|
|
38
|
+
- Discovers site WhatsApp numbers from call-to-action buttons, `wa.me`, and `api.whatsapp.com` links.
|
|
39
|
+
- Generates pre-filled dynamic chat routing so submissions hand off to WhatsApp with lead details intact.
|
|
40
|
+
- **AST-Safe Injection Engine**:
|
|
41
|
+
- Injects Google Tag Manager (GTM) `<head>` container and `<body> <noscript>` fallback with deferred loading options.
|
|
42
|
+
- Initializes Meta Pixel & Meta Conversions API (CAPI) client runtime with cross-event `leadId` deduplication.
|
|
43
|
+
- Hooks form submissions via non-destructive JavaScript event interceptors with zero HTML layout breakage.
|
|
44
|
+
- Supports selective service uninstallation (`removeService`) and complete uninstallation (`--uninstall`).
|
|
45
|
+
- **Unified `.buzl/snapshots/` Rollback & Backup System**:
|
|
46
|
+
- Unifies backup storage under `.buzl/snapshots/<timestamp>_<hash>` to prevent root-level clutter and align with `@mahe_pkm/buzl-html-editor`.
|
|
47
|
+
- Computes 8-character cryptographic SHA-1 content hashes for tamper-proof verification.
|
|
48
|
+
- Automatically creates snapshots before modifying any file, with instant rollback (`--restore [name]`).
|
|
49
|
+
- Supports named snapshots (`--backup [name]`), inspection (`--list-backups`), and backward compatibility with legacy backups.
|
|
50
|
+
|
|
51
|
+
#### ๐ Resilient Google Sheets CRM Engine (`GoogleAppsScript.gs`)
|
|
52
|
+
- **Forward Operational Layout**:
|
|
53
|
+
- Repositions `Handled By` (Column F) and `Comments` (Column G) directly next to `Lead Stage` (Column E) for rapid operational lead qualification.
|
|
54
|
+
- **Official Buzl Navy Blue Header Row**:
|
|
55
|
+
- Styled with official Buzl Navy (`#1E4E9E`), bold white text (`#FFFFFF`), and 32px height (> 8.5:1 WCAG AAA contrast ratio).
|
|
56
|
+
- **Universal Fuzzy Column Matcher**:
|
|
57
|
+
- Case-insensitive, symbol-tolerant header detection (`replace(/[^a-z0-9]/g, '')`) ensures zero data loss during schema upgrades across legacy sheets.
|
|
58
|
+
- **Full-Row Conditional Formatting**:
|
|
59
|
+
- Anchors stage status rules across columns `A2:Z` (`=$E2="Stage"`) so entire rows illuminate according to stage color.
|
|
60
|
+
- **Global 12-Hour Timestamps & Dates**:
|
|
61
|
+
- Dynamically detects spreadsheet timezone and formats event timestamps as `dd-MMM-yyyy hh:mm a` and qualification dates as `dd-MMM-yyyy`.
|
|
62
|
+
- **Top Row Insertion (Row 2)**:
|
|
63
|
+
- New leads automatically insert at Row 2 (top of sheet) immediately below the header.
|
|
64
|
+
- **Shift-Proof Sub-Tab Formulas**:
|
|
65
|
+
- Sub-tabs use `INDIRECT()` filter formulas to query master data without formula displacement when rows insert at top.
|
|
66
|
+
- **Dynamic Team Member Tabs**:
|
|
67
|
+
- Team member tabs named cleanly (strips legacy `"Rep -"` prefix).
|
|
68
|
+
- Strictly moves all team member tabs to the very end of the sheet bar (`moveActiveSheet(ss.getNumSheets())`).
|
|
69
|
+
- Auto-prunes and deletes empty team tabs when a rep has 0 leads.
|
|
70
|
+
- **Full-Column Dropdown Validations**:
|
|
71
|
+
- Applies dropdown validations across entire column ranges (Rows 2 to 1000) for `Lead Stage`, `Is Qualified`, and `Is Spam` across Master and all Sub-Tabs.
|
|
72
|
+
- Dynamic `Handled By` dropdown list in Master Sheet combining `DEFAULT_TEAM_MEMBERS` with existing assigned team members.
|
|
73
|
+
- **Professional Column Widths**:
|
|
74
|
+
- Auto-configures optimal readable column widths for Name, Phone, Email, Service, Comments, and Event Time.
|
|
75
|
+
- **โก Buzl Lead CRM Menu**:
|
|
76
|
+
- 1-click sheet management: Initialize/Upgrade CRM tabs, Sort newest-first, Color-code, Sync team tabs, and Apply dropdowns.
|
|
77
|
+
|
|
78
|
+
#### ๐งช Testing & Reliability
|
|
79
|
+
- 100% test coverage with 37 automated unit and integration tests across:
|
|
80
|
+
- Core injection & rollback (`tests/injector.test.js`)
|
|
81
|
+
- Multi-page relative asset handling (`tests/multipage.test.js`)
|
|
82
|
+
- WhatsApp dynamic discovery (`tests/whatsapp-autofetch.test.js`)
|
|
83
|
+
- Google Apps Script template integrity (`tests/gas-template.test.js`)
|
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Buzl Digital Solutions
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,253 @@
|
|
|
1
|
+
# โก Buzl Tracker & Conversions API (`buzl-tracker`)
|
|
2
|
+
|
|
3
|
+
[](https://github.com/mahe-pkm/Buzl_CAPI)
|
|
4
|
+
[](https://nodejs.org)
|
|
5
|
+
[](LICENSE)
|
|
6
|
+
[](tests/)
|
|
7
|
+
[](package.json)
|
|
8
|
+
|
|
9
|
+
> **All-in-one Node.js CLI & Local Web GUI for automated Google Tag Manager (GTM), Meta Pixel & Conversions API (CAPI), Google Sheets CRM Multi-Tab Sync, and Zoho CRM injection with self-testing.**
|
|
10
|
+
|
|
11
|
+
---
|
|
12
|
+
|
|
13
|
+
## ๐ฏ The Problem This Solves
|
|
14
|
+
|
|
15
|
+
When deploying or optimizing lead-generation landing pages, configuring analytics tags, conversion pixels, CRM webhooks, and spreadsheet logging requires tedious manual labor:
|
|
16
|
+
- Editing `<head>` and `<body>` tags across dozens of HTML files.
|
|
17
|
+
- Writing custom JavaScript form interceptors.
|
|
18
|
+
- Manually capturing UTM parameters, Google Click IDs (`gclid`), and Meta Click IDs (`fbclid`, `_fbc`, `_fbp`).
|
|
19
|
+
- Paying expensive monthly subscription fees for third-party webhook connectors (e.g. Zapier, Make).
|
|
20
|
+
- Fixing broken formulas in spreadsheets when rows insert at the top.
|
|
21
|
+
|
|
22
|
+
**`buzl-tracker` completely automates this entire pipeline in under 60 seconds.**
|
|
23
|
+
|
|
24
|
+
---
|
|
25
|
+
|
|
26
|
+
## ๐๏ธ Multi-Channel Lead Flow Architecture
|
|
27
|
+
|
|
28
|
+
```
|
|
29
|
+
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
|
|
30
|
+
โ Website Visitor Submits โ
|
|
31
|
+
โ HTML Form or WhatsApp โ
|
|
32
|
+
โโโโโโโโโโโโโโโโฌโโโโโโโโโโโโโโโโ
|
|
33
|
+
โ
|
|
34
|
+
โผ
|
|
35
|
+
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
|
|
36
|
+
โ buzl-tracking.js โ
|
|
37
|
+
โ Runtime Client Interceptor โ
|
|
38
|
+
โ - Captures UTMs & Cookies โ
|
|
39
|
+
โ - Generates Unique leadId โ
|
|
40
|
+
โโโโโโโโฌโโโโโโโโฌโโโโโโโโฌโโโโโโโโ
|
|
41
|
+
โ โ โ
|
|
42
|
+
โโโโโโโโโโโโโโโโโโ โ โโโโโโโโโโโโโโโโโโ
|
|
43
|
+
โผ โผ โผ
|
|
44
|
+
โโโโโโโโโโโโโโโโโโโโโโโโโโโ โโโโโโโโโโโโโโโโโโโโโ โโโโโโโโโโโโโโโโโโโโโโโโโโโ
|
|
45
|
+
โ Google Tag Manager(GTM) โ โ Meta Pixel & CAPI โ โ Google Sheets Lead CRM โ
|
|
46
|
+
โ - dataLayer event โ โ - fbq 'Lead' โ โ - Direct Apps Script โ
|
|
47
|
+
โ - Deferred / Instant โ โ - event_id dedup โ โ - Top row lead insert โ
|
|
48
|
+
โโโโโโโโโโโโโโโโโโโโโโโโโโโ โโโโโโโโโโโโโโโโโโโโโ โ - Forward Layout CRM โ
|
|
49
|
+
โ - Auto-Filtered Subtabs โ
|
|
50
|
+
โ - Pruned Rep Tabs โ
|
|
51
|
+
โโโโโโโโโโโโโโโโโโโโโโโโโโโ
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
---
|
|
55
|
+
|
|
56
|
+
## ๐ Quick Start
|
|
57
|
+
|
|
58
|
+
Run inside your landing page project folder (or pass directory as argument):
|
|
59
|
+
|
|
60
|
+
### Option 1: Interactive Terminal Wizard
|
|
61
|
+
```bash
|
|
62
|
+
npx buzl-tracker
|
|
63
|
+
```
|
|
64
|
+
Or target a specific directory:
|
|
65
|
+
```bash
|
|
66
|
+
npx buzl-tracker "path/to/my-website"
|
|
67
|
+
```
|
|
68
|
+
|
|
69
|
+
### Option 2: Local Web GUI Dashboard
|
|
70
|
+
Launch the browser dashboard on `http://localhost:3333`:
|
|
71
|
+
```bash
|
|
72
|
+
npx buzl-tracker --gui
|
|
73
|
+
```
|
|
74
|
+
Or target a specific directory:
|
|
75
|
+
```bash
|
|
76
|
+
npx buzl-tracker "path/to/my-website" --gui
|
|
77
|
+
```
|
|
78
|
+
|
|
79
|
+
### Option 3: Instant Snapshot Backup & Restore
|
|
80
|
+
Create a named snapshot before making changes:
|
|
81
|
+
```bash
|
|
82
|
+
npx buzl-tracker --backup "Pre-Launch Baseline"
|
|
83
|
+
```
|
|
84
|
+
List all saved snapshots:
|
|
85
|
+
```bash
|
|
86
|
+
npx buzl-tracker --list-backups
|
|
87
|
+
```
|
|
88
|
+
Rollback to a specific snapshot or latest:
|
|
89
|
+
```bash
|
|
90
|
+
npx buzl-tracker --restore "Pre-Launch Baseline"
|
|
91
|
+
# or simply revert to latest:
|
|
92
|
+
npx buzl-tracker --restore
|
|
93
|
+
```
|
|
94
|
+
Cleanly remove all injected tracking from your site:
|
|
95
|
+
```bash
|
|
96
|
+
npx buzl-tracker --uninstall
|
|
97
|
+
```
|
|
98
|
+
|
|
99
|
+
---
|
|
100
|
+
|
|
101
|
+
## โก CLI Command Reference
|
|
102
|
+
|
|
103
|
+
| Command / Flag | Alias | Description |
|
|
104
|
+
|---|---|---|
|
|
105
|
+
| `npx buzl-tracker` | โ | Launches the step-by-step interactive terminal wizard. |
|
|
106
|
+
| `npx buzl-tracker --gui` | `-g` | Launches local Web GUI dashboard on port 3333. |
|
|
107
|
+
| `npx buzl-tracker --backup [name]` | `-b` | Creates a point-in-time snapshot backup of all HTML files. |
|
|
108
|
+
| `npx buzl-tracker --list-backups` | โ | Lists all saved snapshot backups on disk. |
|
|
109
|
+
| `npx buzl-tracker --restore [name]` | `-r`, `--rollback` | Reverts all HTML files to the named snapshot (or latest). |
|
|
110
|
+
| `npx buzl-tracker --uninstall` | `-u` | Cleanly strips GTM, Meta Pixel, runtime scripts, and form hooks. |
|
|
111
|
+
| `npx buzl-tracker --help` | `-h` | Displays the help manual and CLI options. |
|
|
112
|
+
|
|
113
|
+
---
|
|
114
|
+
|
|
115
|
+
## ๐ Google Sheets Multi-Tab CRM Engine (`GoogleAppsScript.gs`)
|
|
116
|
+
|
|
117
|
+
`buzl-tracker` comes with an enterprise-grade Google Apps Script CRM engine that turns any Google Sheet into an automated lead dashboard with **zero monthly subscription fees**:
|
|
118
|
+
|
|
119
|
+
### ๐ Key CRM Features:
|
|
120
|
+
1. **Forward Operational Layout**:
|
|
121
|
+
`Handled By` (Col F) and `Comments` (Col G) sit directly adjacent to `Lead Stage` (Col E) for rapid qualification:
|
|
122
|
+
```
|
|
123
|
+
| Name | Location | Phone | Email | Lead Stage | Handled By | Comments | Is Qualified | ...
|
|
124
|
+
```
|
|
125
|
+
2. **Top Row Insertion (Row 2)**:
|
|
126
|
+
Incoming web leads insert directly at **Row 2** (top of sheet) immediately below the header.
|
|
127
|
+
3. **Shift-Proof Sub-Tabs**:
|
|
128
|
+
Status tabs (`New`, `Contacted`, `Qualified`, `Converted`, `Spam`, `Test`) use `=FILTER(INDIRECT(...))` formulas that **never break (#REF!)** when new leads push rows down.
|
|
129
|
+
4. **Full-Row Highlighting Across Columns A:Z**:
|
|
130
|
+
Rows automatically light up with clean, professional status colors when `Lead Stage` is updated.
|
|
131
|
+
5. **Dynamic Team Member Tabs & Auto-Pruning**:
|
|
132
|
+
- Each team member assigned a lead gets an individual tab named after them.
|
|
133
|
+
- Team member tabs are strictly positioned at the very end of the sheet bar.
|
|
134
|
+
- If a team member has 0 leads assigned, their tab is **automatically deleted**.
|
|
135
|
+
6. **Full-Column Dropdown Validations (Rows 2 to 1000)**:
|
|
136
|
+
- `Lead Stage`: `['New', 'Contacted', 'Qualified', 'Converted', 'Spam', 'Test']`
|
|
137
|
+
- `Handled By`: Dynamic dropdown populated from `DEFAULT_TEAM_MEMBERS` + active assigned reps.
|
|
138
|
+
- `Is Qualified` & `Is Spam`: `['No', 'Yes']`
|
|
139
|
+
7. **Official Buzl Navy Blue Header**:
|
|
140
|
+
Header styled in `#1E4E9E` with bold white text (`#FFFFFF`) at 32px height (> 8.5:1 WCAG contrast).
|
|
141
|
+
8. **Global 12-Hour Timestamps**:
|
|
142
|
+
Timestamps formatted as `dd-MMM-yyyy hh:mm a` (dynamic spreadsheet timezone).
|
|
143
|
+
9. **`โก Buzl Lead CRM` Top Menu**:
|
|
144
|
+
1-click sheet management directly inside Google Sheets:
|
|
145
|
+
- `โก Initialize & Upgrade All CRM Tabs`
|
|
146
|
+
- `๐ Sort All Leads (Newest First)`
|
|
147
|
+
- `๐จ Apply Status Color Coding`
|
|
148
|
+
- `๐ฅ Sync Team Member Tabs`
|
|
149
|
+
- `๐ Apply Dropdowns & Layout to All Sheets`
|
|
150
|
+
|
|
151
|
+
### Setup in 30 Seconds:
|
|
152
|
+
1. Open your Google Sheet.
|
|
153
|
+
2. Navigate to **Extensions** > **Apps Script**.
|
|
154
|
+
3. Replace all contents with the code from `Buzl_GoogleAppsScript_Template.gs` (or copy from GUI modal).
|
|
155
|
+
4. Click **Deploy** > **New deployment** > Type: **Web app** > Execute as: **Me** > Access: **Anyone**.
|
|
156
|
+
5. Copy the generated Web App URL and paste it into `buzl-tracker`!
|
|
157
|
+
|
|
158
|
+
---
|
|
159
|
+
|
|
160
|
+
## ๐พ Unified `.buzl/snapshots/` Storage & Content Hashing
|
|
161
|
+
|
|
162
|
+
All snapshot backups are stored inside a single hidden `.buzl` directory in your website root:
|
|
163
|
+
|
|
164
|
+
```
|
|
165
|
+
Your_Website/
|
|
166
|
+
โโโ index.html
|
|
167
|
+
โโโ assets/
|
|
168
|
+
โโโ .buzl/ <-- Shared with @mahe_pkm/buzl-html-editor
|
|
169
|
+
โโโ snapshots/
|
|
170
|
+
โโโ 2026-09-14T10-45-12_a8f3b9c2/ <-- Timestamp + SHA-1 Content Hash
|
|
171
|
+
โโโ backup-manifest.json <-- Full metadata & integrity hash
|
|
172
|
+
โโโ index.html <-- Exact pre-injection copy
|
|
173
|
+
```
|
|
174
|
+
|
|
175
|
+
- **Zero Root Clutter**: Unifies storage under `.buzl` alongside other Buzl ecosystem tools (such as `@mahe_pkm/buzl-html-editor`).
|
|
176
|
+
- **Cryptographic Content Hashing**: Computes an 8-character SHA-1 content hash across all HTML files for tamper-proof verification.
|
|
177
|
+
- **Safe Across Folder Moves**: Backups travel with the website using relative paths.
|
|
178
|
+
- **Backward Compatible**: Automatically detects and restores from legacy `.buzl-backup-*` folders if present.
|
|
179
|
+
|
|
180
|
+
---
|
|
181
|
+
|
|
182
|
+
## ๐ Multi-Page Directory Support
|
|
183
|
+
|
|
184
|
+
For multi-page websites with nested directories (e.g. `/services/sports-physio.html`, `/about/team/doctor.html`):
|
|
185
|
+
- The scanner detects all HTML files regardless of directory nesting depth.
|
|
186
|
+
- Injects proper relative script paths (`assets/js/...`, `../assets/js/...`, `../../assets/js/...`) to guarantee that tracking scripts load accurately without 404 errors.
|
|
187
|
+
|
|
188
|
+
---
|
|
189
|
+
|
|
190
|
+
## ๐ฑ Universal WhatsApp Auto-Fetch
|
|
191
|
+
|
|
192
|
+
- Automatically detects WhatsApp numbers from button `href` attributes, click actions, and phone links.
|
|
193
|
+
- Populates the site configuration automatically.
|
|
194
|
+
- Pre-fills WhatsApp message templates with submitted form data (Name, Service, Location) so inquiries hand off directly to your team's WhatsApp chat.
|
|
195
|
+
|
|
196
|
+
---
|
|
197
|
+
|
|
198
|
+
## ๐ป Programmatic Node.js SDK
|
|
199
|
+
|
|
200
|
+
`buzl-tracker` can also be used programmatically in custom Node.js build scripts:
|
|
201
|
+
|
|
202
|
+
```javascript
|
|
203
|
+
const {
|
|
204
|
+
scanProject,
|
|
205
|
+
applyInjection,
|
|
206
|
+
runVerification,
|
|
207
|
+
createBackup,
|
|
208
|
+
restoreBackup,
|
|
209
|
+
removeTracking
|
|
210
|
+
} = require('buzl-tracker');
|
|
211
|
+
|
|
212
|
+
const projectDir = './my-site';
|
|
213
|
+
|
|
214
|
+
// 1. Scan site and discover forms
|
|
215
|
+
const scan = scanProject(projectDir);
|
|
216
|
+
console.log(`Found ${scan.files.length} HTML files and ${scan.formArchetypes.length} forms`);
|
|
217
|
+
|
|
218
|
+
// 2. Inject tracking
|
|
219
|
+
const config = {
|
|
220
|
+
gtmId: 'GTM-XXXXXXX',
|
|
221
|
+
pixelId: '123456789012345',
|
|
222
|
+
sheetsUrl: 'https://script.google.com/macros/s/XXXXX/exec',
|
|
223
|
+
zohoFormId: '',
|
|
224
|
+
whatsappNumber: '+919876543210'
|
|
225
|
+
};
|
|
226
|
+
|
|
227
|
+
const result = applyInjection(projectDir, scan.files.map(f => f.filePath), config);
|
|
228
|
+
console.log(result.message);
|
|
229
|
+
|
|
230
|
+
// 3. Verify injection integrity
|
|
231
|
+
const testReport = await runVerification(projectDir, scan.files.map(f => f.filePath), config);
|
|
232
|
+
console.log('Self-Test Results:', testReport);
|
|
233
|
+
```
|
|
234
|
+
|
|
235
|
+
---
|
|
236
|
+
|
|
237
|
+
## ๐งช Running Tests
|
|
238
|
+
|
|
239
|
+
The test suite runs with zero external test runners using Node.js core `node:assert`:
|
|
240
|
+
```bash
|
|
241
|
+
npm test
|
|
242
|
+
```
|
|
243
|
+
Runs 37 comprehensive unit & integration tests covering:
|
|
244
|
+
- Safe AST HTML injection & tag de-duplication
|
|
245
|
+
- Multi-page relative asset resolution
|
|
246
|
+
- WhatsApp auto-discovery and button mapping
|
|
247
|
+
- Google Apps Script CRM template synchronization and validation formulas
|
|
248
|
+
|
|
249
|
+
---
|
|
250
|
+
|
|
251
|
+
## ๐ License
|
|
252
|
+
|
|
253
|
+
MIT License ยฉ 2026 Buzl Digital Solutions. See [LICENSE](LICENSE) for details.
|