Просмотр исходного кода

feat(landing): count demo CTA clicks as a GoatCounter event (#2093) (#2094)

Nacho 2 недель назад
Родитель
Сommit
bab308a737
6 измененных файлов с 42 добавлено и 4 удалено
  1. 20 0
      web/app.js
  2. 1 1
      web/features.html
  3. 1 1
      web/home-assistant.html
  4. 1 1
      web/index.html
  5. 1 1
      web/integrations.html
  6. 18 0
      web/src/app.ts

+ 20 - 0
web/app.js

@@ -1617,6 +1617,25 @@ async function initGhMeta() {
     }
     catch { /* sin red */ }
 }
+/* ---------- evento de clic en la demo ---------- */
+// El clic en la demo es la señal de intención más fuerte de la landing y hasta
+// ahora solo contaba como visita normal: se manda como evento de GoatCounter
+// (path demo-click) para verlo en las estadísticas y poder filtrar solo
+// eventos en goatdash. Delegado y en fase de captura para que funcione con
+// cualquier CTA presente o futuro y antes de cualquier navegación.
+function initDemoEvent() {
+    document.addEventListener('click', (e) => {
+        const target = e.target;
+        if (!target || typeof target.closest !== 'function')
+            return;
+        if (!target.closest('a[href*="demo.netpulse.cloudless.club"]'))
+            return;
+        const gc = window.goatcounter;
+        if (!gc || typeof gc.count !== 'function')
+            return;
+        gc.count({ path: 'demo-click', title: 'Demo click', event: true });
+    }, true);
+}
 /* ---------- menú de navegación en móvil ---------- */
 function initNav() {
     const btn = document.getElementById('navBurger');
@@ -1661,6 +1680,7 @@ document.addEventListener('DOMContentLoaded', () => {
     initTrafficRanges();
     initSlider();
     initLightbox();
+    initDemoEvent();
     heroCountUps();
     initGhMeta();
 });

+ 1 - 1
web/features.html

@@ -685,7 +685,7 @@
   </div>
 
   <script src="i18n.js?v=20261113a"></script>
-  <script src="app.js?v=20261019a"></script>
+  <script src="app.js?v=20261117a"></script>
 <script defer src="https://stat.domatix.com/script.js" data-website-id="b9a57c48-cfbb-59fb-af00-e21b868371d9" integrity="sha384-FeSgFWhRpNmUWqmtRLZpDSRTuxgovbVqlyM0OaJpq2IanhF2u3xjYziXsyXR9Kg/" crossorigin="anonymous"></script>
 </body>
 </html>

+ 1 - 1
web/home-assistant.html

@@ -329,7 +329,7 @@ NETPULSE_MQTT_INSTANCE=casa</code>
   </div>
 
   <script src="i18n.js?v=20261113a"></script>
-  <script src="app.js?v=20261019a"></script>
+  <script src="app.js?v=20261117a"></script>
 <script defer src="https://stat.domatix.com/script.js" data-website-id="b9a57c48-cfbb-59fb-af00-e21b868371d9" integrity="sha384-FeSgFWhRpNmUWqmtRLZpDSRTuxgovbVqlyM0OaJpq2IanhF2u3xjYziXsyXR9Kg/" crossorigin="anonymous"></script>
 </body>
 </html>

+ 1 - 1
web/index.html

@@ -888,7 +888,7 @@
   </div>
 
   <script src="i18n.js?v=20261113a"></script>
-  <script src="app.js?v=20261019a"></script>
+  <script src="app.js?v=20261117a"></script>
 <script defer src="https://stat.domatix.com/script.js" data-website-id="b9a57c48-cfbb-59fb-af00-e21b868371d9" integrity="sha384-FeSgFWhRpNmUWqmtRLZpDSRTuxgovbVqlyM0OaJpq2IanhF2u3xjYziXsyXR9Kg/" crossorigin="anonymous"></script>
 </body>
 </html>

+ 1 - 1
web/integrations.html

@@ -401,7 +401,7 @@ go build -o netpulse-integrations ./cmd/integrations-supervisor</code>
   </div>
 
   <script src="i18n.js?v=20261113a"></script>
-  <script src="app.js?v=20261019a"></script>
+  <script src="app.js?v=20261117a"></script>
 <script defer src="https://stat.domatix.com/script.js" data-website-id="b9a57c48-cfbb-59fb-af00-e21b868371d9" integrity="sha384-FeSgFWhRpNmUWqmtRLZpDSRTuxgovbVqlyM0OaJpq2IanhF2u3xjYziXsyXR9Kg/" crossorigin="anonymous"></script>
 </body>
 </html>

+ 18 - 0
web/src/app.ts

@@ -1482,6 +1482,23 @@ async function initGhMeta() {
   } catch { /* sin red */ }
 }
 
+/* ---------- evento de clic en la demo ---------- */
+// El clic en la demo es la señal de intención más fuerte de la landing y hasta
+// ahora solo contaba como visita normal: se manda como evento de GoatCounter
+// (path demo-click) para verlo en las estadísticas y poder filtrar solo
+// eventos en goatdash. Delegado y en fase de captura para que funcione con
+// cualquier CTA presente o futuro y antes de cualquier navegación.
+function initDemoEvent() {
+  document.addEventListener('click', (e) => {
+    const target = e.target as HTMLElement | null
+    if (!target || typeof target.closest !== 'function') return
+    if (!target.closest('a[href*="demo.netpulse.cloudless.club"]')) return
+    const gc = (window as any).goatcounter
+    if (!gc || typeof gc.count !== 'function') return
+    gc.count({ path: 'demo-click', title: 'Demo click', event: true })
+  }, true)
+}
+
 /* ---------- menú de navegación en móvil ---------- */
 function initNav() {
   const btn = document.getElementById('navBurger') as HTMLButtonElement | null
@@ -1520,6 +1537,7 @@ document.addEventListener('DOMContentLoaded', () => {
   initTrafficRanges()
   initSlider()
   initLightbox()
+  initDemoEvent()
   heroCountUps()
   initGhMeta()
 })