Table of Contents
Brokers
The goal is to distribute traffic among brokers based on who offers the highest bid for each geographic region.
This is an early version—please let us know what features you'd like us to add. We use this setup ourselves.
How to Use:
1. Add brokers: Go to Traffic Rules → Brokers and add the brokers you work with.
2. Understand zones and spots: These are key concepts to distinguish.
- Spot — A placement on your site where ads appear (or a redirect destination). The principle is the same: you're showing content from a broker at a specific location.
- Zone — The broker's ad ID. Each broker labels it differently (some call it a “zone,” others a “site”), but it's essentially an ID the broker assigns when you register a property with them.
3. Add zones: Go to Broker Zones and add each zone you want to use. The zone ID comes from the broker's admin panel. For example, “brokerA — zone number 1243712.” You need this ID so the script can pull stats for that specific zone.
4. Create spots: Now define where brokers appear on your site. For example, you have a 100×200 banner and work with 3 brokers. You'd:
- Get a zone ID from each broker for that banner size (3 zones total).
- Create a spot in Site Spots, name it `banner100x200`, and add all 3 zones to it.
- When this spot is displayed, the script will randomly choose which broker's banner to show.
For banners, display them in your template as `<!–SPOT_1–>`, where 1 is the spot ID (visible next to each record).
For redirects, the setup is the same, except in the zone's HTML code field, specify a URL starting with `Location:` (indicating a redirect). For example: `Location:http://broker.com/your_id`
Then you can send traffic to `/cgi/out.php?broker_spot_id=..`
TDS + Mobile Traffic
Here's the typical workflow: You add 2+ brokers, get a banner code from each (creating 2+ broker zones), and make a spot where those zones rotate. In your template, you'd output it as `<!–SPOT_1–>` — the script replaces this tag with the actual broker code.
Suppose a broker offers separate mobile banners. Now you have 2 brokers and 4 zones total. You'd create 2 spots: one for desktop (as described above) and one for mobile using the mobile zone IDs.
Option 1: Separate Templates
If your mobile and desktop templates differ significantly, create two templates: `index` and `mobile_index` (shown to mobile users). Put `<!–SPOT_1–>` in one and `<!–SPOT_2–>` in the other.
Option 2: Single Template with PHP
If you use one template, use conditional PHP:
<?php if ($GLOBALS['SCJ_VISITOR']['mobile']) { ?>
<!--SPOT_2-->
<?php } else { ?>
<!--SPOT_1-->
<?php } ?>
TDS + Brokers
Use this when you want to route some traffic to your own resources (filtered) and the rest to brokers.
1. Go to Traffic Rules → TDS and create a routing scheme. The first rule might be mobile traffic. Set the rule to route all mobile visitors to your resource. 2. Add a second rule: `BROKER_SPOT_1` (where 1 is your broker spot ID).
Now all mobile traffic goes to your resource, and remaining traffic is distributed among brokers by their price bids.
If a broker offers a separate mobile rate, create two TDS rules: one for `BROKER_SPOT_1` (desktop zones) and one for `BROKER_SPOT_2` (mobile zones).
Send Uniques Only
Some brokers count only unique visitors as sales. Depending on the broker and offer, you may want to send only unique hits. Note: some brokers count 1-3 hits from the same user as “unique” anyway.
Fixed Price
A Fixed Price broker type lets you set a flat rate for all countries. This is useful when you've agreed to sell traffic at a fixed price.
How to use:
- Add a Fixed Price broker in Brokers (not added by default to avoid clutter).
- Add zones in Broker Zones. For redirects, write `Location:http://...`. For banners, paste the banner code. Crucially: The Broker Zone ID equals the traffic cost. If you agreed on a $1 rate, the zone ID is `1`, and the script charges that broker $1 per click for all countries.
- In Site Spots, add the zones you created.
In summary: If you have 2 regular brokers and 1 fixed-price broker, the script automatically chooses which broker gets each visitor based on who offers the best rate for that visitor's country.
Cookie Lifetime (Capping)
When a user visits a broker URL or sees an ad, the script records the timestamp. Capping ensures users don't see the same broker multiple times within a set window. Example with 4 banners and 30-second capping:
- 00:00 — User sent to `url1` (sees banner 1)
- 00:10 — User reloads; already saw banner 1, so see banner 2
- 00:20 — User reloads; already saw banners 1 & 2, so see banner 3
- 00:35 — User reloads; banner 4 is available, but banner 1 was shown 35 seconds ago (>30), so show banner 1 again
- 00:37 — Banner 1 was shown 2 seconds ago, banner 2 27 seconds ago, banner 3 17 seconds ago, banner 4 never—show banner 4
- 00:39 — All banners shown <30 seconds ago. The script either resets (forgets all timestamps) or shows a specific banner until 30 seconds pass.
Multisite
Most users manage multiple sites, and often use the same broker across all of them.
If you've added brokers to site 1 and want to use them on site 2, you have two options:
Option 1: Master-Slave (same approach as rotation) Add zones on site 1. On site 2, configure the database connection to point to site 1's database in settings. Site 2 pulls all stats from site 1.
Option 2: Source-Replica Configure brokers only on one site (the source), which pulls broker statistics. Then in CJ Settings → TDS/Brokers → Export, specify which sites (replicas) should receive copies of your broker configuration. These sites appear in Global Admin.
When you update brokers on the source, changes automatically sync to all replicas. When broker stats are pulled, they're also synced. Each domain serves broker ads instantly from its own server, and impression stats for each domain are tracked separately.
Comparison:
- Option 2 duplicates data (downside) but stores it locally on each server (upside). Use this if your servers are on different hosts.
- Option 1 is better if all servers are on the same host.
Broker Tags
Some brokers let you insert custom variables into their code, like:
``` ad_tags = “you can put tags here that will be used by the broker”; ```
The challenge is that you can't insert dynamic tags directly into zone code—caching would interfere. For example, imagine this template:
<html> ... here is the gallery category list <category_list><!--CATEGORY_CUSTOM_NAME-->,</category_list> <!--SPOT_1-->
Let's say spot 1 includes 3 brokers, and one zone wants to include `<!–DESCRIPTION–>` (gallery data). Here's the problem:
Gallery data is fetched once from the database, tags are replaced, and the cache stores plain HTML—served fast without extra queries. But `SPOT_1` is replaced “on the fly” with broker code. If you also need to replace gallery data within the zone HTML, you'd have to fetch gallery data on every hit, spiking server load.
Solution: Prepare the data in advance. Two options:
Option 1: JavaScript
Broker zone:
<script type="application/javascript">
var ad_idzone = "12345667",
ad_width = "300",
ad_height = "250"
ad_tags = "tags needed here";
</script>
Before `<!–SPOT_1–>`, add:
<script type="application/javascript">
var my_tags = "<category_list><!--CATEGORY_CUSTOM_NAME-->,</category_list>";
</script>
Then in the broker code, replace:
``` ad_tags = “tags needed here”; ```
with:
``` ad_tags = my_tags; ```
Option 2: PHP
Before `<!–SPOT_1–>`, add:
``` <? $my_var = “<category_list><!–CATEGORY_CUSTOM_NAME–>,</category_list>”; ?> ```
Then in the broker code, replace:
``` ad_tags = “tags needed here”; ```
with:
``` ad_tags = <?=$my_var?>; ```
Use PHP when the broker block isn't JavaScript.
Adding Brokers
For most brokers, you just need standard fields: API key, login, and password.
Traffic Stars
Traffic Stars is different. In the API Key field, enter two colon-separated values: `client_id:client_secret`. Example: `lkdjflksjd213:344343kdkksk`
TwinRed
TwinRed also differs:
- In the API Key field, enter two colon-separated values: `client_id:client_secret`. Example: `lkdjflksjd213:344343kdkksk`
- For zone_id, use the format `publisherID:siteID:zoneID` (find this in the broker's admin panel)
