
Security News
Axios Supply Chain Attack Reaches OpenAI macOS Signing Pipeline, Forces Certificate Rotation
OpenAI rotated macOS signing certificates after a malicious Axios package reached its CI pipeline in a broader software supply chain attack.
@adkit.so/google-tracking
Advanced tools
Platform-agnostic Google Ads tracking wrapper with TypeScript support
A lightweight, type-safe Google Ads (gtag.js) tracking wrapper for JavaScript & TypeScript applications.
Platform-agnostic wrapper for Google Ads conversion tracking with TypeScript support, debug logging, and automatic script loading.
npm install @adkit.so/google-tracking
import GOOGLE from '@adkit.so/google-tracking';
// 1. Initialize
GOOGLE.init({ tagId: 'AW-XXXXXXXXXX' });
// 2. Track conversions
GOOGLE.trackConversion('AW-XXXXXXXXXX/YYYYYYY', { value: 29.99, currency: 'USD' });
That's it! 🎉
npm install @adkit.so/google-tracking
Initialize the tracker as early as possible in your application entry point (e.g., main.ts, App.jsx, index.js).
import GOOGLE from '@adkit.so/google-tracking';
GOOGLE.init({
tagId: 'AW-XXXXXXXXXX',
debug: true, // Enable console logs
enableLocalhost: true, // Enable on localhost for testing
});
// Basic conversion (no value)
GOOGLE.trackConversion('AW-XXXXXXXXXX/CONVERSION_LABEL');
// Conversion with value
GOOGLE.trackConversion('AW-XXXXXXXXXX/CONVERSION_LABEL', {
value: 99.99,
currency: 'USD',
});
// Conversion with transaction ID (for deduplication)
GOOGLE.trackConversion('AW-XXXXXXXXXX/CONVERSION_LABEL', {
value: 99.99,
currency: 'USD',
transaction_id: 'ORDER_12345',
});
If you need separate instances for different parts of your application:
import { createGoogleTracking } from '@adkit.so/google-tracking';
const tracker1 = createGoogleTracking();
tracker1.init({ tagId: 'AW-FIRST_TAG' });
const tracker2 = createGoogleTracking();
tracker2.init({ tagId: 'AW-SECOND_TAG' });
| Option | Type | Default | Description |
|---|---|---|---|
tagId | string | string[] | '' | Required. Single Tag ID or array of Tag IDs (e.g., AW-XXXXX) |
debug | boolean | false | Enable styled console logs with background colors |
enableLocalhost | boolean | false | Enable tracking on localhost (useful for testing) |
GOOGLE.init({
tagId: ['AW-FIRST_TAG', 'AW-SECOND_TAG'],
debug: true,
});
| Parameter | Type | Description | Example |
|---|---|---|---|
value | number | Monetary value of the conversion | 99.99 |
currency | string | ISO 4217 currency code | 'USD', 'EUR' |
transaction_id | string | Unique ID for deduplication | 'ORDER_12345' |
// E-commerce purchase
GOOGLE.trackConversion('AW-XXXXX/purchase_label', {
value: 149.99,
currency: 'USD',
transaction_id: 'order_abc123',
});
// Lead form submission
GOOGLE.trackConversion('AW-XXXXX/lead_label');
// Sign-up conversion
GOOGLE.trackConversion('AW-XXXXX/signup_label', {
value: 10.0,
currency: 'USD',
});
// Subscription conversion
GOOGLE.trackConversion('AW-XXXXX/subscribe_label', {
value: 29.0,
currency: 'USD',
transaction_id: 'sub_xyz789',
});
Useful if you need to conditionally run logic based on whether gtag has loaded.
if (GOOGLE.isLoaded()) {
GOOGLE.trackConversion('AW-XXXXX/label');
} else {
console.log('Google Ads not loaded yet');
}
const config = GOOGLE.getConfig();
console.log(config?.tagId); // 'AW-XXXXX'
When debug: true is passed to init(), you'll see beautiful styled console logs:
GOOGLE.init({
tagId: 'AW-XXXXX',
debug: true,
});
This package is written in TypeScript and bundles type definitions.
import type { GoogleTrackingConfig, ConversionParams } from '@adkit.so/google-tracking';
const config: GoogleTrackingConfig = {
tagId: 'AW-XXXXX',
debug: true,
};
const params: ConversionParams = {
value: 100,
currency: 'USD',
transaction_id: 'order_123',
};
AW-XXXXXXXXXX)AW-XXXXXXXXXX/CONVERSION_LABELdebug: true in init() to see detailed logsenableLocalhost: true if testing locallyLearn more about Google Ads conversion tracking:
Check out our other tracking packages:
@adkit.so/meta-pixelContributions are welcome! Please feel free to submit a Pull Request.
MIT
Made with ❤️ by AdKit
If this package helped you, please consider giving it a ⭐️ on GitHub!
FAQs
Platform-agnostic Google Ads tracking wrapper with TypeScript support
We found that @adkit.so/google-tracking demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Security News
OpenAI rotated macOS signing certificates after a malicious Axios package reached its CI pipeline in a broader software supply chain attack.

Security News
Open source is under attack because of how much value it creates. It has been the foundation of every major software innovation for the last three decades. This is not the time to walk away from it.

Security News
Socket CEO Feross Aboukhadijeh breaks down how North Korea hijacked Axios and what it means for the future of software supply chain security.