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_visit to 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_visit is 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.
Setup Web Analytics: GA4, GTM, Yandex.Metrica, and Amplitude
We often see: conversion rate 1.2%, traffic grows, but conversion stays flat. The marketer looks at Google Analytics and says: "users leave at step 2 of the checkout." The developer opens the same step — no errors, Sentry is silent. So it's not a JS bug, but a UX issue or skewed data from analytics. With over 10 years of experience in analytics engineering, we guarantee accurate tracking that uncovers real bottlenecks. Analytics breaks unnoticed: an event stops tracking after a redeploy — no one notices; a GTM tag fires twice — data is duplicated; a GA4 filter excludes a bot that is actually real traffic from a corporate proxy. An audit of your current tags will find the cause within a week.
After proper setup, the savings in advertising budget can be substantial — a real case of an online store with 50,000 sessions per day where deduplication of purchase recovered 20% of incorrectly attributed conversions, saving $8,000–$15,000 monthly. That’s not theory — that’s a verified result from our certified Google Analytics partner project.
Why do GA4 events duplicate and how to fix it?
Universal Analytics is gone, replaced by GA4's event-based model. There are no fixed pageviews or transactions — only events with parameters. This is more flexible but requires proper event design. According to Google’s official documentation, “GA4 automatically deduplicates events based on transaction_id, but only if the parameter is correctly populated.” Many implementations miss this.
Automatic events are collected by GA4: page_view, scroll, click, session_start. Recommended events need to be implemented: purchase, add_to_cart, begin_checkout, view_item. Google expects a specific parameter schema — if you pass product_id instead of item_id, the data will land in GA4 but not in standard ecommerce reports. Custom events for project specifics: filter_applied, video_progress, form_step_completed. Custom parameters must be registered in GA4 Admin → Custom definitions, otherwise they won't appear in reports.
A common mistake is the purchase event being duplicated. Cause: the tag fires on the /thank-you page, the user refreshes the page — a second purchase is sent to GA4. Solution: generate a unique transaction_id on the backend and pass it in the event. In our experience, 80% of e-commerce stores have this issue. GA4 deduplicates based on it (in theory — verify with DebugView). Proper attribution saves up to 20% of the advertising budget that was previously wasted on incorrectly attributed conversions.
How to set up the data layer to avoid data loss?
GTM is a tool for managing tags without code deployment. But "no code" doesn't mean "no architecture." The data layer is the foundation. We pass data from the application to GTM via dataLayer.push(). Structure: event + contextual data. For e-commerce: before opening a product page — push with product data. GTM tag reads from the data layer, not from the DOM.
window.dataLayer = window.dataLayer || [];
dataLayer.push({
event: 'view_item',
ecommerce: {
items: [{
item_id: 'SKU-12345',
item_name: 'Product name',
price: 1990.00,
currency: 'USD'
}]
}
});
Bad practice: GTM tag parses the DOM — looks for the price in span.price, the name in h1. This breaks with any layout change. Good practice: always use the data layer. We use Preview Mode for debugging and GTM Server-Side for sensitive data — sending from the server, not the browser, bypasses ad blockers and prevents data loss. A properly implemented data layer reduces tracking errors by 95%.
How does Yandex.Metrica complement web analytics?
For a Russian audience, Metrica is a must — especially Webvisor. Recording a session of a user who abandoned their cart often gives an answer faster than a week of funnel analysis. Goals in Metrica: event-based (via ym(COUNTER_ID, 'reachGoal', 'GOAL_NAME')) or automatic (button click, page visit). Integration with CRM via Metrica Plus — passing offline conversions. Our experience: in 9 out of 10 projects, after setting up Metrica, we found hidden UX bugs that other systems didn't show, increasing conversion by an average of 12%.
What does product analytics give in Amplitude?
Amplitude is a product tool, unlike marketing-oriented GA4 and Metrica. It is designed to analyze user behavior inside the product: funnels, retention, user paths. Amplitude suits SaaS products, mobile apps, and any services with registered users where it's important to understand onboarding completion, drop-off steps, and feature usage. Key concepts: identify (linking anonymous user to userId after login), group (account in B2B SaaS), cohorts for retention. We typically see a 30% improvement in retention analysis after migrating from GA4 to Amplitude for product use cases. Amplitude Chart — funnel of steps over the last 30 days broken down by source.
Monitoring Data Quality
Analytics without monitoring is a black box. We set up:
- GA4 Realtime — check after every deploy that key events are coming in
- Alerting in GA4 — anomaly in the number of
purchase events (sharp drop = something broke)
- GTM Preview in staging before production
- Manual funnel tests once a week — simply go through the buyer journey and verify everything is tracked
What we check after each deploy
- All recommended events present in DebugView
- No duplicates (count
purchase per 100 sessions)
- Data layer structure unchanged after frontend update
What the work includes
| Component |
Description |
| Audit of existing tags |
Check current GTM tags, data layer, duplicates, and errors |
| Event schema design |
Documentation: event list, parameters, triggers |
| GA4 + GTM setup |
Create configuration, tags, custom definitions |
| Yandex.Metrica |
Install counter, create goals, set up Webvisor |
| Amplitude (optional) |
Set up client and server SDK, cohorts |
| QA and monitoring |
Testing in Preview Mode, alerting |
| Training and handover |
Access, instructions for adding new events, console |
Process and timeline
- Audit of existing tags and data (2 days)
- Event schema design (2 days)
- Data layer development and tag setup (3–5 days)
- QA in Preview Mode and staging (2 days)
- Deploy and dashboard setup (1 day)
| Scenario |
Timeline |
| Basic GA4 + GTM setup |
1 week |
| Full e-commerce tracking + Metrica |
2–3 weeks |
| Server-side GTM + Amplitude |
3–5 weeks |
Cost is calculated individually. Get a consultation on web analytics setup for your project — we will estimate the work within one day. Contact us to get started with a free audit of your current tracking.