Get started
Web quickstart: your first attributed sign-up
Tie a website's sign-ups to the ads that brought them: two keys, @traqio/web on the site, a server SDK on the backend, a tracking link to your site.
This guide ties a website's sign-ups to the ads that brought them. It takes four pieces: two keys, the browser SDK on the site, a server SDK on the backend, and a tracking link that lands on the site. At the end, a click on your link followed by a sign-up comes back attributed to the link's campaign — by the id of that click, not by a guess. For an app, the app quickstart is the one to follow.
Early access
Steps#
Create the two keys#
In the console, open your product, then Integrations → SDK. Create:
- a web key (
tq_web_…), listing every origin that runs the site —https://www.example.com,https://app.example.com. It is public: it goes in your pages, and works only from those origins; - a server key (
tq_sk_…). It is a secret, shown once: put it in your backend's environment asTRAQIO_SECRET_KEY.
- a web key (
Add @traqio/web to the site#
npm install @traqio/webimport { Traqio } from "@traqio/web"; Traqio.init({ sdkKey: "YOUR_WEB_KEY" }); // tq_web_… — a WEB key, not the app keyOnce, as early as possible, on every page — the web SDK page shows it for React, Vue, Angular and a plain
<script>tag. When a visitor arrives from your link, it keeps the trackID in a first-party cookie on your domain.Report the sign-up from the backend#
npm install @traqio/nodecomposer require traqio/traqio-phppip install traqioimport { Traqio, trackIdFromRequest } from "@traqio/node"; const traqio = new Traqio({ secretKey: process.env.TRAQIO_SECRET_KEY! }); // where the account is created const result = await traqio.signup({ userId: user.id, trackId: trackIdFromRequest(req) }); console.log(result.trackId, result.attribution); // "matched" { network: "meta", campaignId: "…", … }use Traqio\Laravel\Facades\Traqio; use Traqio\TrackId; // where the account is created — TRAQIO_SECRET_KEY is read from .env $result = Traqio::signup((string) $user->id, TrackId::fromRequest($request)); logger()->info('traqio', ['trackId' => $result->trackId, 'campaign' => $result->attribution->campaignId]);import os from traqio import Traqio, track_id_from_request traqio = Traqio(os.environ["TRAQIO_SECRET_KEY"]) # where the account is created result = traqio.signup(str(user.pk), track_id_from_request(request)) print(result.track_id, result.attribution) # matched Attribution(network='meta', campaign_id='…', …)Where the account is created, once. The sign-up request carries the cookie, so the trackID is read off it. Each SDK page — Node.js, PHP / Laravel, Python — covers its frameworks, errors and purchases.
Create a tracking link to your site#
In Links, create a link: the ad network, the campaign id the network gives you — it is what joins clicks to spend — and, as Website destination, the page the ad should open. Put the link's click URL in the ad. A click lands on that page, on every device, with the trackID added:
https://www.example.com/pricing?traq_click=3f7c…&traq_source=meta&traq_campaign=summerClick, sign up, read the answer#
Open the link's click URL in a browser, then sign up on the site with a new account. Your backend's
signupcall answersmatched, and its attribution names the link's network and campaign.Where to read it
The response of the server call gives the attribution at once. In the console, the ROAS report counts the sign-up as a web conversion of the link's campaign, beside its installs.
Next#
- Report purchases and subscriptions with
track, with their value, currency and payment id — they follow the user to the campaign that acquired them. - Read web attribution for the rules: one click per identity, the attribution window, the last click before the sign-up.
Frequently asked questions#
- Why does my test sign-up come back without a trackID?
- The visit did not start from the tracking link, the page did not run @traqio/web, or your backend is on another domain than the site, so the traq_click cookie does not reach it. In the last case, send Traqio.getTrackId() from the browser with the sign-up form.
- Why does a second test sign-up answer claimed?
- A click credits one identity: once a click is bound to a user, another user cannot claim it. Click the link again for every test user — each click is a new trackID.