{"modulePath":"github.com/GoCodeAlone/workflow-plugin-cms","version":"v0.1.10","isLatest":true,"isStandardLibrary":false,"goos":"all","goarch":"all","docs":"# package analytics\n\nPackage analytics injects per-tenant analytics snippets into served HTML.\n\nPer gocodealone-multisite SPEC.md V25: when the tenant's multisite.yaml has analytics.google.measurement\\_id set, the host injects gtag.js into rendered pages. Without an ID set, ⊥ injection.\n\nThe actual snippet is rendered by workflow-plugin-analytics — this package only owns the per-tenant gating + HTML splice point.\n\n## Functions\n\n```go\nfunc InjectGtag(html []byte, cfg TenantConfig) []byte\n```\nInjectGtag returns html with a \\`\\\u003cscript\u003e\\` block inserted before the closing \\`\\\u003c/head\u003e\\` tag. If no \\\u003c/head\u003e is present (rare — degraded HTML) the snippet is prepended.\n\nIf cfg is disabled, returns html unchanged.\n\nThe snippet content is intentionally minimal here. Production wires this through workflow-plugin-analytics, which has a more complete gtag rendering surface; this implementation is the fallback used when that plugin is not loaded.\n\n```go\nfunc RenderGtagSnippet(cfg TenantConfig) []byte\n```\nRenderGtagSnippet returns the gtag.js script tag block. The measurement ID is interpolated; anonymize\\_ip is gated.\n\nThe measurement\\_id must match the GA4 pattern (G-XXXXXXXXXX). Anything else is escaped at the JS string boundary to prevent injection.\n\n## Types\n\n```go\ntype TenantConfig struct {\n\tGoogleMeasurementID string\n\tAnonymizeIP         bool\n}\n```\nTenantConfig is the per-tenant analytics config (from multisite.yaml).\n\n```go\nfunc (c TenantConfig) Enabled() bool\n```\nEnabled returns true iff this config opts the tenant into analytics injection.\n\n","path":"github.com/GoCodeAlone/workflow-plugin-cms/analytics","name":"analytics","synopsis":"Package analytics injects per-tenant analytics snippets into served HTML.","isRedistributable":true}
