Connecting a website hosted elsewhere
Your website lives on your own hosting, Qubix has no access to its server, and you want its visits, clicks, forms and events in Qubix together with everything else. Such a website is connected with code that runs in the visitor's browser: the page stays on your server, and the browser reports to Qubix what happens on it. One code serves the website whatever sources buy traffic for it.
If the website is uploaded to Qubix, nothing has to be added to it — see Hosting a website in Qubix.
How to connect the website
- Open the 网站 section and click + 外部网站.
- Enter the website's name and its address, for example
https://my-landing.com. Leave 跟踪事件 on; tick 记录会话 if you also want session recordings. Click 创建. - Open the website card. On the 外部网站 tab, find the Connect the site block.
- In the Qubix domain list, pick the domain the code will load from. It is one of the domains of the Domains section, not the panel address. If the list is empty, add a domain first.
- Put the code on every page of the website in one of the two ways below and publish the pages.
If both 跟踪事件 and 记录会话 are off for the website, the block shows no code — a message instead and, with the right to manage websites, the 跟踪事件 switch right in the block. A switch you turn on takes effect within a minute.
Way 1: a script from the Qubix domain
Copy the Script from the Qubix domain block and paste it into the <head> of every page. The code looks like this:
<script src="https://your-qubix-domain.com/sdk.js" data-site="WEBSITE-ID" async></script>
The data-site attribute carries the identifier of this website, so the code names the website itself. With 记录会话 on, the block has a second line — the session recording script.
The page sends visits and events straight to the Qubix domain, and the visitor's identifier is kept in the browser storage of your website's domain. This way works while 跟踪事件 or 记录会话 is on for this website or for any other external website on the same domain: the permission belongs to the domain. Without it Qubix does not hand the page the visitor's identifier, and every event counts as a new visitor. http and https, as well as an address with www. and without it, count here as different domains.
Way 2: through your nginx
The Through your nginx block holds two location blocks and the script. Add the blocks to the server section of your website and the script to the <head> of every page:
location /pwa-api/ {
proxy_pass https://your-qubix-domain.com/pwa-api/;
proxy_set_header Host your-qubix-domain.com;
proxy_ssl_server_name on;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
set $qubix_visitor_ip $remote_addr;
if ($http_cf_connecting_ip) { set $qubix_visitor_ip $http_cf_connecting_ip; }
proxy_set_header X-Qubix-Visitor-IP $qubix_visitor_ip;
}
location = /sdk.js {
proxy_pass https://your-qubix-domain.com/sdk.js;
proxy_set_header Host your-qubix-domain.com;
proxy_ssl_server_name on;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
}
<script src="/sdk.js" data-site="WEBSITE-ID" async></script>
The /pwa-api/ and /sdk.js addresses of your website now lead to Qubix, and the browser sees one website: the visitor's identifier is a cookie of your website's domain. Events that come through your server are accepted whatever the switches say.
The last three lines of the first block pass Qubix the visitor's IP address — from Cloudflare when your website stands behind it. Qubix determines the visitor's country from this address. Without these lines every visitor gets the address and the country of your server. Qubix takes the address from this header as it arrives and does not check who set it.
What the code counts
The code counts by itself, with no calls of yours:
- the visit — when a page is opened not from another page of the same website: from an ad, by a link from elsewhere or by typing the address. The ad is taken from the
ad_idparameter of the address; - the following pages of the same website continue that visit and do not count new ones;
- clicks and forms — on every page.
Registrations and deposits arrive as the network's postback, as usual, or your website's backend sends them — see If your website has its own backend. Your own steps on the page are marked with sdk.sendEvent — see Mark up your own steps.
The numbers are on the Statistics tab of the website card — see Your landing's statistics.
If your website has its own backend
Your backend — in PHP or anything else — can send registrations and deposits to Qubix itself, without the browser: with a request to the postback address, the same way an affiliate network does.
- Take the postback address in the card of a domain with the 回传 role — see Domain settings.
- On the page, take the click identifier from the tracking code —
sdk.getTrackingParams().click_id— and pass it to your backend together with the application, for example in a hidden form field. - When the backend has accepted a registration or a deposit, it calls the postback address with that identifier:
# registration
curl "https://pb.your-domain.com/postback?subid=CLICK_ID&status=lead&from=mysite"
# deposit
curl "https://pb.your-domain.com/postback?subid=CLICK_ID&status=sale&payout=50¤cy=USD&from=mysite"
The conversion lands on its click, campaign and ad. All the parameters and their synonyms are in Parameter passing and postback.
Which campaign a visit belongs to
A visit belongs to the tracker campaign whose entry point covers the address of the page — its domain and path. If several campaigns stand on that entry point, the click picks one of them by the same rules as on a website hosted in Qubix — see One landing, several sources. The entry points of a campaign are picked from the domains of the Domains section.
If no campaign has an entry point on the page's address, visits and events are still counted for the website, but they belong to no campaign. Conversions of such visits are not sent to Facebook: the Facebook event mapping is taken from the source of the visit's campaign — see FB CAPI.