@lydio/google-tag
v3.0.2
Published
Google Analytics gtag integration node for Lydio
Maintainers
Readme
@lydio/google-tag
Canonical URL:
https://alexstevovich.com/a/lydio-google-tag-nodejs
Software URL:
https://midnightcitylights.com/software/lydio-google-tag-nodejs
Google Analytics gtag node for Lydio.
@lydio/google-tag provides a ready-to-use Google Analytics integration node.
It generates both the external gtag.js loader and inline configuration script,
ready to embed into any Lydio-generated HTML document.
Installation
npm install @lydio/google-tagExample
import GoogleTag from '@lydio/google-tag';
const analytics = new GoogleTag('G-XXXXXXXXXX');
console.log(analytics.toHtml());
/*
<script async src="https://www.googletagmanager.com/gtag/js?id=G-XXXXXXXXXX"></script>
<script>window.dataLayer = window.dataLayer || [];
function gtag(){dataLayer.push(arguments);}
gtag('js', new Date());
gtag('config', 'G-XXXXXXXXXX');</script>
*/Nonce Example
const analytics = new GoogleTag('G-XXXXXXXXXX', { nonce: 'secure123' });Features
- Generates both required script tags in one fragment.
- Automatically includes async for the loader.
- Supports optional nonce for strict CSP.
License
Licensed under the Apache License 2.0.
Trademark
“Lydio” and related marks are trademarks of Alex Stevovich.
See TRADEMARK.md for details.
