Skip to main content

Overview

Instead of sending API requests directly to Statsig, you can set up your own environment that proxies requests from your custom domain name to Statsig. This makes it less likely for tracking blockers to intercept your APIs, and allows you to capture more data. There are many ways to set up custom proxies. We are showing instructions for a few common service providers here.
Important: Default Endpoints Are BlockedThe default Statsig endpoints (like /v1/log_event) are commonly blocked by tracking blockers. To ensure your proxy works effectively:
  1. Use a custom endpoint name specific to your product (e.g., /v1/my-product-data instead of /v1/log_event)
  2. Rewrite the URL in your proxy to map your custom endpoint to the actual Statsig endpoint (log_event)
  3. Do not use passthrough for the endpoint path - you must rewrite it
Additionally, your proxy should not try to deserialize the payload body. This will improve robustness by reducing risk of integration issues from Server SDK -> Proxy -> Client SDK, as well as improve efficiency of the proxy. For example, client SDKs may change encoding to compress payloads, which would break if your proxy does not accept the new format (e.g. gzip).

Approaches

AWS CloudFront

Prerequisites

  • Write access to your DNS settings.
  • Write access on your AWS CloudFront and Lambda console.
  • Access to a SSL certificate for your custom domain.

Setup

On your AWS CloudFront console,
  • Click on Create distribution.
  • In the Origin section,
    • Set the Origin Domain to api.statsig.com.
    • Set the Protocol to HTTPS only.
    Origin section
  • In the Default cache behavior section,
    • Set Viewer protocol policy to Redirect HTTP to HTTPS.
    • Set Allowed HTTP methods to GET, HEAD, OPTIONS, PUT, POST, PATCH, DELETE.
    • In the Cache Key and origin requests subsection, allow all headers and parameters to be forwarded to the Origin, and allow CORS requests for the Origin.
    Default cache behavior section
  • In Function associations section,
    Function associations section
You can use the following javascript code snippet in your Lambda@Edge function. This example rewrites a custom endpoint /v1/my-product-data to the Statsig endpoint /v1/log_event:
Check your SDK’s documentation for the specific configuration options available for customizing endpoint URLs.