Docs menu · GTM DataLayer

Docs / Integrations

GTM with DataLayer

For Laravel, PHP, or any site using Google Tag Manager

Select Container Type:

sGTM Mode: Use your PixelFly-hosted Server-Side GTM container for full GTM control.

Proxy Mode: PixelFly routes events directly to ad platforms. No sGTM server needed.

1

Setup DataLayer Events

Push e-commerce events to the dataLayer from your application code. Use GA4 standard event format.

// Example: Add to Cart event
dataLayer.push({
  event: 'add_to_cart',
  ecommerce: {
    currency: 'BDT',
    value: 1500,
    items: [{
      item_id: 'SKU123',
      item_name: 'Product Name',
      price: 1500,
      quantity: 1
    }]
  },
  user_data: {
    email: 'customer@example.com',
    phone: '+8801712345678'
  }
});
2

Create your sGTM container in PixelFly

PixelFly → Containers → new sGTM container. Note its server URL (e.g. https://abcd1234.pixelfly.io, or your custom domain). See sGTM Hosting.

3

Import the web and server containers

Import each into Google Tag Manager (Admin → Import Container): the web one into your website’s GTM, the server one into your server GTM.

Meta Pixel, GA4, Google Ads and TikTok in the browser; Meta CAPI, GA4 and TikTok on the server; reload protection; COD Order Protection (off until you switch it on).

4

Fill in your IDs

  • Web: the Google Tag’s server container URL = your sGTM URL; Meta Pixel ID-000 = your Pixel ID.
  • Server: Facebook CAPI Pixel ID and access token; GA4-Server Side Measurement ID.
  • Cash on delivery? See COD with our sGTM containers.
5

Publish & test

Publish the server container, then the web one, and check both in GTM Preview.

2

Import the proxy container

Import it into your website’s Google Tag Manager (Admin → Import Container). It’s built on our sGTM web container and sends server-side events to PixelFly’s API.

Download Proxy Web Container (.json)
3

Fill in your API key and IDs

  • PixelFly API Key = your container’s API Key (container page in PixelFly).
  • Meta Pixel ID-000 and GA4-FM ID (your GA4 Measurement ID).
  • PixelFly - Server URL: leave https://track.pixelfly.io/e unless you set up a tracking domain.
  • In PixelFly, add Receivers for the platforms the server-side events should reach (Meta, GA4, TikTok, Google Ads).
4

Publish & test

Publish and check GTM Preview and PixelFly’s event logs. Cash on delivery? See COD with our proxy container.

DataLayer Event Reference

// Page View
dataLayer.push({ event: 'page_view' });

// Purchase
dataLayer.push({ ecommerce: null });
dataLayer.push({
  event: 'purchase',
  eventId: 'purchase_ORDER-123',   // unique per order
  payment_method: 'cod',           // or 'bkash', 'card', …
  ecommerce: {
    transaction_id: 'ORDER-123',
    currency: 'BDT',
    value: 5000,
    tax: 0,
    shipping: 100,
    items: [{ item_id: 'SKU123', item_name: 'Product', price: 2500, quantity: 2 }]
  },
  user_data: {
    email: 'customer@example.com',
    phone: '+8801712345678'
  }
});

We use cookies to enhance your experience, analyze site traffic, and for marketing purposes. By continuing to use our site, you consent to our use of cookies. Learn more