PageSourceSearch

https://www.readyt.ai/assets/js/analytics.js

js readyt.ai collected 2026-10-05 12:29:45 UTC 6,201 bytes, 97 lines download raw bytes

1/* Readyt site analytics — PostHog EU (même projet que app.readyt.ai → funnel complet).
2   Chargé APRÈS l'affichage (requestIdleCallback) pour ne pas peser sur le rendu initial :
3   on garde le replay + les surveys, mais PostHog s'initialise en arrière-plan. */
4(function () {
5  /* ---- Attribution UTM des liens vers l'app (avant le guard dev pour être testable en local).
6     Chaque lien app.readyt.ai est décoré au clic : utm_source=readyt-site,
7     utm_medium=nav|footer|body, utm_campaign=<page>, utm_content=<texte du lien>.
8     Les UTM déjà présents sur un lien ne sont jamais écrasés. */
9  function pageSlug() {
10    var p = location.pathname.replace(/\/$/, "").replace(/^\//, "").replace(/\.html$/, "");
11    return (p || "home").replace(/\//g, "-").slice(0, 60);
12  }
13  function decorate(a) {
14    var href = a.getAttribute("href") || "";
15    if (href.indexOf("app.readyt.ai") === -1) return;
16    try {
17      var u = new URL(href, location.origin);
18      if (u.searchParams.get("utm_source")) return; // déjà tagué à la main : on respecte
19      var area = a.closest("footer, .rfoot") ? "footer" : (a.closest("nav, header, .navbar, .top") ? "nav" : "body");
20      u.searchParams.set("utm_source", "readyt-site");
21      u.searchParams.set("utm_medium", area);
22      u.searchParams.set("utm_campaign", pageSlug());
23      u.searchParams.set("utm_content", ((a.textContent || "").trim().toLowerCase().replace(/\s+/g, "-").replace(/[^a-z0-9-]/g, "") || "link").slice(0, 40));
24      a.setAttribute("href", u.href);
25    } catch (e) { /* URL invalide : on ne touche pas */ }
26  }
27  // Au clic (couvre aussi les liens injectés dynamiquement), en phase capture pour passer avant la navigation.
28  document.addEventListener("click", function (ev) {
29    var a = ev.target && ev.target.closest ? ev.target.closest("a[href]") : null;
30    if (a) decorate(a);
31  }, true);
32
33  // pas de tracking en dev local
34  if (/^(localhost|127\.0\.0\.1)$/.test(location.hostname)) return;
35
36  /* Google Analytics 4 (gtag) — async, non-bloquant. Propriété "Readyt V2". */
37  window.dataLayer = window.dataLayer || [];
38  window.gtag = function () { dataLayer.push(arguments); };
39  gtag("js", new Date());
40  gtag("config", "G-64XL66ZH9L");
41  (function () { var g = document.createElement("script"); g.async = true; g.src = "https://www.googletagmanager.com/gtag/js?id=G-64XL66ZH9L"; document.head.appendChild(g); })();
42
43  /* Snippet officiel posthog-js (stub léger, injecte array.js à l'init) */
44  !function(t,e){var o,n,p,r;e.__SV||(window.posthog=e,e._i=[],e.init=function(i,s,a){function g(t,e){var o=e.split(".");2==o.length&&(t=t[o[0]],e=o[1]),t[e]=function(){t.push([e].concat(Array.prototype.slice.call(arguments,0)))}}(p=t.createElement("script")).type="text/javascript",p.crossOrigin="anonymous",p.async=!0,p.src=s.api_host.replace(".i.posthog.com","-assets.i.posthog.com")+"/static/array.js",(r=t.getElementsByTagName("script")[0]).parentNode.insertBefore(p,r);var u=e;for(void 0!==a?u=e[a]=[]:a="posthog",u.people=u.people||[],u.toString=function(t){var e="posthog";return"posthog"!==a&&(e+="."+a),t||(e+=" (stub)"),e},u.people.toString=function(){return u.toString(1)+".people (stub)"},o="init capture register register_once register_for_session unregister unregister_for_session getFeatureFlag getFeatureFlagPayload isFeatureEnabled reloadFeatureFlags updateEarlyAccessFeatureEnrollment getEarlyAccessFeatures on onFeatureFlags onSurveysLoaded onSessionId getSurveys getActiveMatchingSurveys renderSurvey canRenderSurvey canRenderSurveyAsync identify setPersonProperties group resetGroups setPersonPropertiesForFlags resetPersonPropertiesForFlags setGroupPropertiesForFlags resetGroupPropertiesForFlags reset get_distinct_id getGroups get_session_id get_session_replay_url alias set_config startSessionRecording stopSessionRecording sessionRecordingStarted captureException loadToolbar get_property getSessionProperty createPersonProfile opt_in_capturing opt_out_capturing has_opted_in_capturing has_opted_out_capturing clear_opt_in_out_capturing debug getPageViewId captureTraceFeedback captureTraceMetric".split(" "),n=0;n<o.length;n++)g(u,o[n]);e._i.push([i,s,a])},e.__SV=1)}(document,window.posthog||[]);
45
46  function boot() {
47    posthog.init("phc_pGhWZtwwY2d5iFAgtHq8ywCDKZgKaHCzqeu9dMPunnF8", {
48      api_host: "https://eu.i.posthog.com",
49      ui_host: "https://eu.posthog.com",
50      defaults: "2025-05-24",
51      capture_pageview: true,   // site HTML statique multi-pages : $pageview à CHAQUE chargement (pas "history_change" qui est pour les SPA)
52      capture_pageleave: true
53    });
54
55    /* Events nommés (en plus de l'autocapture) */
56    document.addEventListener("click", function (ev) {
57      var a = ev.target && ev.target.closest ? ev.target.closest("a[href]") : null;
58      if (!a) return;
59      var href = a.getAttribute("href") || "";
60      if (href.indexOf("app.readyt.ai") !== -1) {
61        posthog.capture("cta_signup_click", {
62          cta_text: (a.textContent || "").trim().slice(0, 60),
63          page: location.pathname
64        });
65      } else if (/^https?:\/\//.test(href) && href.indexOf("readyt.ai") === -1) {
66        /* Lien sortant vers un site tiers : event nommé pour savoir OÙ ça part */
67        var dom = "";
68        try { dom = new URL(href).hostname.replace(/^www\./, ""); } catch (e) {}
69        posthog.capture("outbound_click", {
70          domain: dom,
71          href: href.slice(0, 200),
72          link_text: (a.textContent || "").trim().slice(0, 60),
73          page: location.pathname
74        });
75      }
76    }, true);
77
78    document.addEventListener("submit", function (ev) {
79      var f = ev.target;
80      if (f && f.tagName === "FORM") {
81        posthog.capture("form_submit", {
82          form: f.className || f.id || "form",
83          page: location.pathname
84        });
85      }
86    }, true);
87  }
88
89  /* Différé après l'affichage : ne bloque pas le rendu initial */
90  if ("requestIdleCallback" in window) {
91    requestIdleCallback(boot, { timeout: 3000 });
92  } else if (document.readyState === "complete") {
93    setTimeout(boot, 1200);
94  } else {
95    window.addEventListener("load", function () { setTimeout(boot, 1200); });
96  }
97})();

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.