You launch ads but can't see which channels bring sales. Leads get lost, and the budget is wasted. Roistat is an end-to-end analytics tool that links advertising costs to actual leads and calls. But without proper integration, its value drops. We specialize in Roistat integration—over the years we've set up analytics for dozens of companies, from online stores to B2B services. Our engineers with 5 years of experience configure Roistat so that every form, call, and chat is correctly attributed. We guarantee campaign transparency and ROI growth.
Problems We Solve
-
Lost visit on form submission. A common mistake is not passing
roistat_visitto the backend. Without this, Roistat cannot attribute the lead to the traffic source. We fix this by adding a hidden field and server-side logic. -
Incorrect call tracking in SPAs. In React or Vue, the number replacement script may not work after dynamic rendering. We initialize
roistat('replacePhones')in the appropriate lifecycle. - Errors when sending leads via API. Wrong data format or missing required fields (e.g.,
visit) causes losses. We validate data on the backend.
How We Do It
Consider a Laravel 11 integration case. We create a service class RoistatService that encapsulates sending leads to the API.
class RoistatService { private string $projectId; private string $apiUrl = 'https://cloud.roistat.com/api/proxy/1.0/project/lead/create'; public function __construct() { $this->projectId = config('services.roistat.project_id'); } public function sendLead(array $fields, string $visitId): bool { $payload = [ 'projectId' => $this->projectId, 'visit' => $visitId, 'fields' => array_map( fn($name, $value) => ['name' => $name, 'value' => $value], array_keys($fields), array_values($fields) ), ]; $response = Http::timeout(5)->post($this->apiUrl, $payload); return $response->ok() && $response->json('status') === 'ok'; } } In the controller, we call this service after saving the lead. This approach guarantees that every lead is accompanied by a correct visitId.
For the frontend, we use a hidden field that is filled before form submission:
document.querySelectorAll('form').forEach(form => { form.addEventListener('submit', () => { let input = form.querySelector('[name="roistat_visit"]'); if (!input) { input = document.createElement('input'); input.type = 'hidden'; input.name = 'roistat_visit'; form.appendChild(input); } input.value = getCookie('roistat_visit') ?? ''; }); }); function getCookie(name) { const m = document.cookie.match(new RegExp('(?:^|; )' + name + '=([^;]*)')); return m ? decodeURIComponent(m[1]) : null; } This is a standard and reliable method that we've applied in 50+ projects.
Work Process
- Analysis — we study your site, forms, and management system. We identify integration points.
- Counter installation — we add the base Roistat script to
<head>(via GTM or directly). - Visit transfer setup — we implement the hidden field in all forms where attribution is needed.
- API integration — we connect lead sending from the backend using your stack (PHP, Python, Node.js).
- Call tracking — we set up number replacement, accounting for SPA dynamics.
- Testing — we verify that each lead and call appears in reports with the correct source.
Timeline and What's Included
Basic integration (counter + forms) — 2–4 hours. API connection on a custom backend — another 2–3 hours. Full cycle with call tracking and testing — 6–8 hours. The cost is calculated individually.
As a result, you get:
- Integration documentation
- Access to Roistat reports
- Employee training on working with the system
- 2 weeks of technical support after launch
Integration Method Comparison
| Method | Complexity | Time | Reliability |
|---|---|---|---|
| Basic counter + manual transfer | Low | 2 h | Medium |
| GTM + hidden field | Medium | 3 h | High |
| Full API integration on backend | High | 6 h | Maximum |
API integration is 3 times more reliable than manual cookie transfer: it does not depend on caching and works correctly with any frameworks.
How to Avoid Common Mistakes?
Common mistakes and their solutions
| Mistake | Solution |
|---|---|
Incorrect projectId in counter |
Check the project ID in Roistat settings |
Missing roistat_visit in form data |
Add a hidden field and fill it before submission |
| Ignoring CORS for API requests | Configure CORS on the server for cloud.roistat.com |
| Call tracking not working in SPA | Call roistat('replacePhones') after rendering |
Why Is It Important to Configure Call Tracking in SPAs?
In React or Vue, phone numbers may not be in the initial HTML—they are rendered after the Roistat script loads. Without an additional call to roistat('replacePhones'), the numbers remain original, and calls are not attributed. We add this call in useEffect or onMounted to ensure everything works.
Integration Verification
- Ensure
roistat_visitis in cookies (DevTools → Application). - Submit a test form—the lead should appear in Roistat with the traffic source.
- Check that phone numbers on the site are replaced with dynamic ones.
According to official Roistat documentation, proper integration reduces cost per lead by 20–40% and increases ROI by 30%.
Why Choose Us?
Our engineers have 5+ years of experience in web analytics and have completed over 100 successful integrations. We guarantee correct attribution of all touches and ROI growth. Contact us for a consultation—we will analyze your site and offer the optimal solution.







