When setting up server‑side tracking with Google Tag Manager (sGTM) you might wonder whether a new Klar pixel is required. The short answer is **no** – you can use the pixel you already have configured for your store. This article explains why an extra pixel isn’t necessary, shows you how to locate the required numeric datasourceId, and provides the essential steps to implement server‑side tracking correctly.
Do You Need a Separate Klar Pixel?
Each Klar pixel you create in the Store Configurator generates a unique datasourceId (the numeric part of the pixel URL, e.g., 123456789 in https://123456789.your-domain.com/). This ID is all that is required for server‑side tracking. Adding another pixel would only duplicate the same functionality and could lead to unnecessary DNS entries.
Existing pixel works for both client‑side and server‑side tracking.
No additional CNAME records are needed; the original DNS configuration remains valid.
You only need to reference the numeric datasourceId in your server‑side payloads.
Finding Your datasourceId
Open the pixel URL you created in Klar (it looks like https://YOUR_NUMERIC_ID.your‑domain.com/). The number before the first dot is the datasourceId.
Example:
https://123456789.your-domain.com/ → datasourceId = 123456789
Configuring Server‑Side Tracking in sGTM
Follow these steps to send events from your server to Klar using the existing datasourceId.
Validate your domain in Klar’s Store Configurator if you haven’t already.
Set up the tracking endpoint – all events must be POSTed to:
https://september.durchsichtig.xyz/server-side-event/{EVENT_NAME}Include required HTTP headers in every request:
Content‑Type:
application/jsonx‑serverside‑ip: the customer’s IP address (mandatory for server‑side tracking)
Build the request payload using the BaseEvent schema (see section below). The
dataSourceIdfield must contain the numeric ID you retrieved in the previous step.Deploy the code in your server environment (Node, PHP, Python, etc.) and test each event type.
Base Event Schema (required fields)
All events share the following structure. Replace placeholder values with your actual data.
{
"eventName": "VisitEvent", // specific event type
"createdAt": "2024-04-11T11:11:15.783Z", // ISO‑8601 timestamp
"pageUrl": "https://your‑shop.com/page",
"septemberId": "a1b2c3d4e5f6g7h8", // 16‑character nanoid per user
"googleAnalyticsId": "GA1.2.1234567890.1234567890",
"facebookId": "fb.1.1234567890.1234567890",
"dataSourceId": "523072759", // <-- numeric ID from your pixel
"referrer": "https://google.com",
"hasGivenConsent": true,
"customerId": "cust_123456",
"screen": "1920x1080",
"shopSystem": "shopify"
}
Example: VisitEvent Request
Below is a complete cURL example that sends a VisitEvent to Klar.
curl -X POST https://september.durchsichtig.xyz/server-side-event/VisitEvent \
-H "Content-Type: application/json" \
-H "x-serverside-ip: 203.0.113.45" \
-d '{
"eventName": "VisitEvent",
"pageTitle": "Best Product of the World",
"createdAt": "2024-04-11T11:11:15.783Z",
"pageUrl": "https://your‑shop.com/home",
"septemberId": "a1b2c3d4e5f6g7h8",
"googleAnalyticsId": "GA1.2.1234567890.1234567890",
"facebookId": "fb.1.1234567890.1234567890",
"dataSourceId": "523072759",
"referrer": "https://google.com",
"hasGivenConsent": true,
"customerId": "cust_123456",
"screen": "1920x1080",
"shopSystem": "shopify"
}'
Other Event Types
Implement the same pattern for every Klar event you need to track. The full list includes:
VisitEvent
ProductViewedEvent
AddToCartEvent
RemoveFromCartEvent
UpdateCheckoutEvent
PaymentInfoEvent
ShippingInfoEvent
OrderEvent
UpdateABGroupEvent
CustomConversionEvent
Each event adds a few specific fields (e.g., productId, checkoutId, customConversionId) while keeping the BaseEvent fields identical.
Troubleshooting Common Errors
If Klar returns a 400 status, check the “X‑Klar‑Failure” response header for the exact cause:
read-headers – missing or malformed required headers.
get-body – request body is absent or not JSON.
invalid-json – JSON syntax error in the payload.
Correct the identified issue and resend the request. For unresolved problems, contact Klar support.
Additional Resources
Official guide: “Setting up the Klar Pixel via Server‑Side Tracking” (step‑by‑step instructions).
Data‑privacy snippet: add the provided text to your privacy policy as described in the Klar Pixel datasource settings.
Support: reach out to Klar customer support for any further questions.
