Hi
Product
Features
Security
Difference
Limits
FAQ
Pricing
Doc & Api
Get started free
NEXT-GEN LINK INFRASTRUCTURE

Stop guessing.
Start improving.

Deploy custom domains, ISO country routing, A/B split testing, PathLock™ PIN gates, and deterministic revenue attribution in under two minutes.

Get startedAccess our plans
Platform
  • Country & Device Routing
  • Weighted A/B Testing
  • Revenue Attribution (EPC)
  • Dynamic QR Studio
Security & Access
  • PathLock™ PIN Protection
  • Branded URL Masking
  • Click Limits & Expiration
  • Custom OpenGraph Cards
Developers
  • REST API & SDK Quickstart
  • Real-Time Click Telemetry
  • Signed Webhooks & Events
  • Full Documentation Hub
Legal & Trust
  • Privacy Policy (GDPR)
  • Terms of Service
  • No-Refund Policy
  • Dashboard Overview
LShorter Logo
LShorter© 2026 LShorter Inc.
Built on Cloudflare Edge Network
All 310+ Cloudflare Edge PoPs Operational
Privacy•Terms•Refunds
LShorter Logo
LShorter
HiHiProductProductFeaturesFeaturesSecuritySecurityDifferenceDifferenceLimitsLimitsFAQFAQPricingPricing
Doc & ApiDoc & Api
SDK & API Reference
Endpoints REST, clés Bearer et SDK TypeScript
Routage intelligent & Géo
Ciblage pays, OS mobile et redirection Edge
PathLock™ & Sécurité
Protection par code PIN, expiration et masquage
Télémétrie & Analytics
Flux de clics en direct, attribution et webhooks
RESSOURCESDocumentation

Documentation

Get started
LShorter Logo
LShorter
All guides & documentation

Percentage Routing & A/B Testing API

Intelligently split click traffic across landing page variants to maximize conversion rates.

4 min read•Official Edge Documentation
Percentage Routing & A/B Testing API

Overview & Architecture

Percentage routing (A/B Testing) directs a defined proportion of traffic to different page variations (e.g., 50% to Variant A, 50% to Variant B, or 70% / 15% / 15%).

Routing decisions execute directly on Cloudflare Edge servers during the network handshake, with zero client scripts or visible layout flicker.

Key Principles

Core architectural pillars ensuring high performance, isolation, and security.

01Weighted Edge Distribution
Define custom percentage weights (sum = 100%) between the primary URL and A/B variations.
02Zero Flicker
Routing happens before HTML page load, eliminating visual shifts for visitors.
03Comparative Conversion Analytics
Analyze click volumes, conversion rates, and revenue generated by each variant in your dashboard.
SDK Integration

Implementation & SDK Examples

Ready-to-use TypeScript code snippets and configuration examples for your integrations.

1. Creating an A/B Test via SDK

Associate variations with their respective percentage weights:

create-ab-test.ts
typescript
12345678910111213141516171819
import { lshorter } from "@/lib/lshorter";
const abLink = await lshorter.links.create({
url: "https://your-store.com/landing-a",
slug: "promo-split",
mainWeight: 50, // 50% to landing A
abVariations: [
{
id: "var_b",
targetUrl: "https://your-store.com/landing-b",
weight: 50, // 50% to landing B
name: "Variant B (Green Button)",
},
],
tags: ["ab-test", "marketing-q4"],
});
console.log("A/B Testing short link active:", abLink.shortUrl);
// Output: https://lsho.cc/promo-split
REST API Specification

API Endpoints & Reference

Direct HTTP request methods, parameters schema, authentication, and responses.

PATCH

Configure A/B Test Routing

Bearer <API_KEY>60 to 1,400 req/min (by plan)
https://lsho.cc/api/v1/links/:id/ab

Configures or updates percentage traffic split weights across multiple landing page variants.

Path Parameters

ParameterTypeRequiredDescriptionExample
idstringRequiredShort link slug or ID.promo-split

Request Body Parameters

ParameterTypeRequiredDescriptionExample
mainWeightnumberRequiredPercentage of traffic sent to the primary target URL (0 to 100).50
abVariationsobject[]RequiredArray of variant configurations.[{"id": "var_b", "targetUrl": "https://store.com/landing-b", "weight": 50, "name": "Variant B (Green Button)"}]
abVariations[].idstringRequiredUnique variant key.var_b
abVariations[].targetUrlstring (url)RequiredDestination URL for this variant.https://store.com/landing-b
abVariations[].weightnumberRequiredPercentage weight allocated to this variant.50
abVariations[].namestringOptionalHuman-readable label for dashboard comparison.Variant B (Green Button)

Request Examples

bash
1234567891011121314
curl -X PATCH "https://lsho.cc/api/v1/links/promo-split/ab" \
-H "Authorization: Bearer $LSHORTER_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"mainWeight": 50,
"abVariations": [
{
"id": "var_b",
"targetUrl": "https://store.com/landing-b",
"weight": 50,
"name": "Variant B (Green Button)"
}
]
}'

Response Payload

200 OKA/B testing weights updated.
response-200.json
json
12345678910111213141516
{
"id": "link_ab_991823",
"slug": "promo-split",
"shortUrl": "https://lsho.cc/promo-split",
"mainWeight": 50,
"abVariations": [
{
"id": "var_b",
"targetUrl": "https://store.com/landing-b",
"weight": 50,
"name": "Variant B (Green Button)",
"clicksCount": 0
}
],
"status": "active"
}

A/B Testing Link Structure

Payload confirming percentage routing weights:

response.json
json
1234567891011121314151617
{
"id": "link_ab_991823",
"slug": "promo-split",
"shortUrl": "https://lsho.cc/promo-split",
"targetUrl": "https://your-store.com/landing-a",
"mainWeight": 50,
"abVariations": [
{
"id": "var_b",
"targetUrl": "https://your-store.com/landing-b",
"weight": 50,
"name": "Variant B (Green Button)",
"clicksCount": 128
}
],
"status": "active"
}

Recommended Best Practices

Expert tips to maximize performance, resilience, and link security.

Recommendation 01

Ensure total weight sums to exactly 100% (mainWeight + sum of variation weights = 100).

Recommendation 02

Run tests until reaching statistically significant sample sizes (at least 500 to 1,000 clicks per variant).

Recommendation 03

Test only one major variable per experiment (e.g. headline vs hero image) to clearly identify causality.

Previous guideConversion Tracking & Financial Metrics (Amount & Count)Next guideSocial Sharing & Dynamic Open Graph API

Related Guides & APIs

Quickstart & REST API Reference
Quickstart & REST API Reference
Integrate intelligent edge link shortening, real-time analytics, and conversion tracking with our high-performance REST API and TypeScript SDK.
Read guide & API
Dynamic Routing & Edge Geolocation
Dynamic Routing & Edge Geolocation
Redirect visitors to contextual URLs based on their origin country or continent with ultra-low latency.
Read guide & API