Identify requests as internal traffic

Identify Requests as Internal Traffic

How do you filter out internal traffic (like employees or testers) from Tweakwise reports?

Because traffic to Tweakwise APIs is typically server-to-server, we only see the IP address of your server, not the end-user. This makes standard IP-based filtering impossible. To solve this, you pass a custom TWN-Source header in your API requests. This allows you to explicitly tag internal traffic and easily filter it out within Tweakwise reports.

Here are the steps to implement this functionality.

Implementation Steps

1. Identify Internal Users on Your Server

Determine a method within your application to identify internal users. Common methods include checking for an active admin session, a specific corporate IP address hitting your server, or a custom cookie.

2. Append the TWN-Source Header

When constructing your request to the Tweakwise endpoints, add the TWN-Source header to requests made by internal users.

Assign it a clearly identifiable string, such as Internal or Dev-Team.

Example HTTP Request:

GET /navigation HTTP/1.1
Host: gateway.tweakwise.com
TWN-Source: Internal-Traffic

3. Magento Implementation Example

If you are developing in Magento, your development team needs to intercept the API call to Tweakwise and inject the TWN-Source header whenever an internal user is detected (e.g., via a specific customer group or IP check in the Magento backend).

Notes & Important Considerations

  • Consistency is key: Always use the exact same string for your internal traffic header (e.g., always Internal-Traffic). If you use dynamic variables (like individual usernames), your reports will become heavily fragmented and difficult to read.
  • Case sensitivity: While HTTP headers are generally case-insensitive, it is best practice to keep the capitalization of your header value consistent.

FAQ

Can I just pass the end-user's IP address to Tweakwise for filtering?
No. Because of the server-to-server architecture, Tweakwise relies on the TWN-Source header for reliable traffic segmentation. It is purpose-built for this exact reporting need.

Where do I filter this in the Tweakwise app?
Once the header is actively being sent, you can go to the Analytics/Reports section in the Tweakwise backend and use the "Request Source" filter to include or exclude the value you defined (e.g., Internal-Traffic).