跳到主要内容

A landing button that leads to the offer

The classic setup: a visitor comes from the ad to your landing page, reads it, and leaves for the offer by a button. In Qubix this is the Landing campaign target with an offer picked: Qubix serves your index.html as you uploaded it, with additions of its own — a <base href> tag, so the page's relative links work at the campaign address; the Browser SDK library, when the website's 跟踪事件 switch is on; the session recording script, when 记录会话 is on. The move to the offer is done with the Browser SDK library: with 跟踪事件 on it is already on the page, with it off you connect it yourself.

The main thing you get for free: the offer is picked by the server. Splitting several offers by weight, pinning the offer to the visitor, substituting the tags into the link — all of that has already happened by the time the page opens. Your code only asks the SDK for the ready-made address and puts it on the button.

What you need first​

  • The landing is uploaded to Qubix — the Landing pages section, type 落地页. How to upload — Uploading a landing page.
  • A campaign with the target Landing and an offer: the campaign has your website and an offer picked (or several offers with a weighted split).
  • A domain connected and active — Domains.

AI mode​

Both steps — connecting the SDK and putting the offer on the button — are done with one ask to the AI assistant. Open your website card: the Landing pages window → your landing → the Files tab, the index.html file. Call the assistant right in that window and describe the task in plain words:

  • "Connect the SDK and make the «Play» button lead to the offer with the tags carried over";
  • "Make every button of the .btn class lead to the offer";
  • "Why doesn't the button get the offer? Here is my code: …".

The assistant writes a ready-made block for your page — all that's left is to insert and save.

Manual mode​

The same two steps in your own code — to understand exactly what was inserted, or to do it your own way.

Step 1. Connect the SDK​

Add one line to the landing's index.html — the script is served from the same domain the campaign runs on:

index.htmlHTML
<script src="/sdk.js" defer></script>

No settings and no keys needed: the context — which offer was picked, which tags came with the click — is already in a cookie the server set, and the SDK reads it itself.

With the website's 跟踪事件 switch on, Qubix adds this line to the page itself, and the step can be skipped; a line you added yourself is not added a second time.

Step 2. Put the offer on the button​

Set the link right after the page loads:

index.htmlHTML
<a id="cta" class="btn" href="#">Play</a>

<script>
window.addEventListener('DOMContentLoaded', function () {
var offer = sdk.getOffer()
if (offer) {
document.getElementById('cta').href = sdk.buildOfferUrl(offer.url)
}
})
</script>

Or at the moment of the click — when there are several buttons or the address is only needed on action:

HTML
<button id="cta" class="btn">Claim the bonus</button>

<script>
document.getElementById('cta').addEventListener('click', function () {
var offer = sdk.getOffer()
if (offer) {
location.href = sdk.buildOfferUrl(offer.url)
}
})
</script>

What each call does:

  • sdk.getOffer() — returns the offer picked for this visitor: { id, url }. If the page was opened outside a campaign (for example, you are looking at it directly), it returns null — so the if (offer) check is mandatory.
  • sdk.buildOfferUrl(offer.url) — builds the final link: substitutes the macros in the offer address ({click_id}, {sub1}…, {all_source_params}) with the values that came with the click. The click id is carried over by itself — the affiliate network receives it under the spelling it expects.

Split and pinning already work​

If the campaign has several offers with weights, the server picks one of them before serving the page and remembers the pick for the visitor. A repeat visit by the same person gets the same offer. Your landing code needs nothing for this: sdk.getOffer() always returns the pick already made, it never rolls the dice again.

Statistics — also on its own​

With the website's 跟踪事件 switch on, the campaign visit, the clicks and the forms are counted by themselves — no "visit pixel", no on-load calls needed from you. With the switch off, Qubix doesn't add the library and doesn't count visits, clicks and forms by itself; the server counts page views either way. Connect the library as in step 1 and call sdk.track() after the page loads — it counts the visit and starts counting clicks and forms. Your own funnel steps — scrolled to the form, opened a dialog, clicked the button — mark up by hand:

JavaScript
sdk.sendEvent('cta_click', { place: 'hero' })

Where the events land and how to see statistics on them — Your landing's statistics.

Don't confuse this with the prelanding

With the 预着陆页 + PWA + 报价 target the button leads not to the offer but to the app's storefront — there you call sdk.showStore() instead of sdk.buildOfferUrl. If you need the move to the offer, the campaign target must be Landing with an offer picked. The prelanding scenario is covered in SDK on your prelanding.

Campaign targetWhere the button leadsCall
Landing with an offerto the offer, with the tagssdk.buildOfferUrl(sdk.getOffer().url)
预着陆页 + PWA + 报价to the app's storefrontsdk.showStore()

Verify​

  1. Assemble the campaign link (an example is under the entry point on the campaign's 设置 tab, or in the 广告示例 URL block in the domain card) and open it in a private browser window.
  2. The button must get the offer address with the tags filled in — visible in the browser's status bar on hover or in the developer tools.
  3. The visit shows up in the 受众 section on the 点击 tab — with 跟踪事件 on or after a sdk.track() call; your own events (sdk.sendEvent) — in the visitor card on the «Events» tab, with a short delay.

What's next​