Tags

Browse tags or submit a tag to reach digital engineers worldwide.

Command Palette

Search for a command to run...

Server-Side GA4 Event Tracking
Send GA4 events from server-side using Measurement Protocol
const measurementId = 'G-XXXXXXXXXX';
const apiSecret = 'your-api-secret';

async function sendGA4Event(eventName, params) {
  const url = `https://www.google-analytics.com/mp/collect?measurement_id=${measurementId}&api_secret=${apiSecret}`;
  
  const payload = {
    client_id: generateClientId(),
    events: [{
      name: eventName,
      params: params
    }]
  };
  
  await fetch(url, {
    method: 'POST',
    body: JSON.stringify(payload)
  });
}

// Usage
sendGA4Event('purchase', {
  transaction_id: 'T12345',
  value: 25.42,
  currency: 'USD'
});

tag.directory

Meta Pixel Standard Event
Standard Meta Pixel pageview event
fbq('track', 'PageView');

tag.directory

Enhanced GA4 Pageview with Custom Parameters
Enhanced GA4 pageview tracking with custom parameters
gtag('config', 'GA_MEASUREMENT_ID', {
  page_title: document.title,
  page_location: window.location.href,
  custom_parameter_1: 'value1',
  custom_parameter_2: 'value2'
});

tag.directory

Cookiebot Consent Manager Integration
Integrate Cookiebot consent manager with GA4 and Meta Pixel
function onCookiebotConsentUpdate() {
  const consent = Cookiebot.consent;
  
  if (consent.statistics) {
    // Initialize analytics
    gtag('consent', 'update', {
      'analytics_storage': 'granted'
    });
  }
  
  if (consent.marketing) {
    // Initialize marketing pixels
    fbq('consent', 'grant');
  }
}

Cookiebot.onConsentReady = onCookiebotConsentUpdate;
Cookiebot.onDecline = onCookiebotConsentUpdate;

tag.directory

Facebook Pixel PageView
Facebook Pixel PageView tracking tag for Google Tag Manager. Tracks page views and initializes the Facebook Pixel.
<!-- Facebook Pixel Code -->
<script>
!function(f,b,e,v,n,t,s)
{if(f.fbq)return;n=f.fbq=function(){n.callMethod?
n.callMethod.apply(n,arguments):n.queue.push(arguments)};
if(!f._fbq)f._fbq=n;n.push=n;n.loaded=!0;n.version='2.0';
n.queue=[];t=b.createElement(e);t.async=!0;
t.src=v;s=b.getElementsByTagName(e)[0];
s.parentNode.insertBefore(t,s)}(window, document,'script',
'https://connect.facebook.net/en_US/fbevents.js');
fbq('init', '{{Pixel ID}}');
fbq('track', 'PageView');
</script>
<noscript><img height="1" width="1" style="display:none"
src="https://www.facebook.com/tr?id={{Pixel ID}}&ev=PageView&noscript=1"
/></noscript>
<!-- End Facebook Pixel Code -->

leopoldus11

Cookiebot Consent Manager Integration
Integrate Cookiebot consent manager with GA4 and Meta Pixel. Updates consent preferences when user changes their cookie preferences.
function onCookiebotConsentUpdate() {
  const consent = Cookiebot.consent;

  if (consent.statistics) {
    // Initialize analytics
    gtag('consent', 'update', {
      'analytics_storage': 'granted'
    });
  }

  if (consent.marketing) {
    // Initialize marketing pixels
    fbq('consent', 'grant');
  }
}

Cookiebot.onConsentReady = onCookiebotConsentUpdate;
Cookiebot.onDecline = onCookiebotConsentUpdate;

leopoldus11