How to Connect Pipedrive with Google Analytics 4 via API and GTM
Quick Summary
Most sales teams live in their CRM. Most marketers live in Google Analytics. The gap between those two worlds costs businesses real revenue — campaigns that drive qualified leads get attributed to the wrong source, closed deals never trace back to the ad spend that generated them, and nobody can answer the one question that actually matters: which marketing touchpoints produce customers? This guide shows you exactly how to bridge Pipedrive CRM and Google Analytics 4 using three complementary techniques: passing contact IDs through UTM links, injecting deal and user data into the dataLayer via Google Tag Manager, and unifying CRM and GA4 user identities so every behavioral event connects to a real pipeline record.
Why Does Connecting Pipedrive CRM to GA4 Matter for Revenue Attribution?

Marketing attribution breaks down the moment a prospect leaves your website and enters your CRM. GA4 tracks sessions, events, and conversions on the website side. Pipedrive CRM tracks what happens after — meetings booked, proposals sent, deals won. Without a deliberate connection between the two systems, you’re running attribution on half the data.
What Does a Unified Pipedrive and GA4 Data Model Look Like?
When you connect both systems properly, you unlock a data model where every closed deal in Pipedrive traces back to a GA4 session, a traffic source, a campaign, and a specific behavioral path on your website. Concretely, this enables:
- Full-funnel attribution — tie revenue in Pipedrive to the exact campaign, keyword, or content piece that generated the contact
- Qualified lead scoring by source — identify which traffic channels produce deals that actually close, not just form fills
- CRM-informed audience segmentation — push Pipedrive contact segments back into Google Ads via GA4 for retargeting
- Behavioral context for sales reps — surface what a contact viewed on your website before their first meeting
According to Google’s own GA4 documentation, the platform supports user-level analysis through the User-ID feature and custom dimensions — capabilities purpose-built for CRM integration scenarios exactly like this one.
What Are the Three Core Integration Methods Covered in This Guide?
Before diving into implementation, here’s a clear map of the three techniques this guide covers and how they relate to each other:
| Method | What It Does | Technical Requirement |
|---|---|---|
| UTM + Contact ID passing | Tags inbound leads with their Pipedrive contact ID via URL parameters | URL builder, Pipedrive API, form handler |
| dataLayer injection via GTM | Pushes CRM data into GA4 events from your website or app | GTM container, Pipedrive API or webhook |
| GA4 User-ID unification | Assigns a consistent user identity across anonymous sessions and known CRM contacts | GA4 User-ID configuration, server-side logic |
Each method builds on the previous one. Passing contact IDs creates the identifiers. DataLayer injection carries the data. User-ID unification stitches it all together into a coherent user journey.
How Do You Pass Pipedrive Contact IDs Through UTM Links?
Why Does Contact ID Passing Solve the Attribution Gap?
The fundamental attribution problem between GA4 and Pipedrive CRM happens at the moment a visitor submits a form and becomes a contact. At that point, GA4 knows a conversion happened. Pipedrive knows a new contact exists. But neither system knows what the other knows — because there’s no shared identifier.
Passing the Pipedrive contact ID back through the UTM chain solves this by creating a persistent identifier that both systems can reference. The contact ID becomes the Rosetta Stone that lets you join GA4 behavioral data with Pipedrive deal data in a BI tool, a data warehouse, or directly in Looker Studio.
How Do You Build the Contact ID Passing Workflow?
The implementation follows a specific sequence. Here’s the full workflow:
Step 1 — Capture UTM parameters at form submission
Configure your web forms to capture UTM parameters from the URL and pass them as hidden fields alongside the form submission. Use a JavaScript snippet that reads URLSearchParams from window.location.search and populates hidden form fields with utm_source, utm_medium, utm_campaign, utm_content, and utm_term.
javascript
// On form page load — populate hidden UTM fields
const params = new URLSearchParams(window.location.search);
['utm_source', 'utm_medium', 'utm_campaign', 'utm_content', 'utm_term'].forEach(param => {
const field = document.querySelector(`input[name="${param}"]`);
if (field) field.value = params.get(param) || '';
});
Step 2 — Create the Pipedrive contact via API and store UTM data
When your backend receives the form submission, call the Pipedrive CRM Persons API to create the contact. Store the captured UTM parameters as custom fields on the Person record so they persist alongside the contact in Pipedrive.
javascript
// POST to Pipedrive Persons API
const response = await fetch('https://api.pipedrive.com/v1/persons?api_token=YOUR_API_TOKEN', {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({
name: formData.name,
email: [{ value: formData.email, primary: true }],
// Custom fields for UTM storage (use your field keys)
utm_source_field_key: formData.utm_source,
utm_medium_field_key: formData.utm_medium,
utm_campaign_field_key: formData.utm_campaign
})
});
const { data } = await response.json();
const pipedriveContactId = data.id; // Store this
Step 3 — Return the contact ID to the frontend and fire a GA4 event
Once Pipedrive returns the new contact’s ID, send it back to the browser and fire a GA4 generate_lead event that includes the contact ID as a custom parameter. This creates the linkage between the GA4 session and the Pipedrive record.
javascript
// Fire GA4 event with Pipedrive contact ID
gtag('event', 'generate_lead', {
pipedrive_contact_id: pipedriveContactId,
utm_source: formData.utm_source,
utm_campaign: formData.utm_campaign
});
How Do You Use GTM and the dataLayer to Inject Pipedrive Data Into GA4?
What Is dataLayer Injection and Why Does It Enable Richer Attribution?
Google Tag Manager’s dataLayer acts as a communication channel between your website’s application logic and your analytics tags. Instead of hardcoding GA4 event parameters directly into your page code, you push structured data objects into the dataLayer — and GTM reads those objects and passes the relevant values to GA4 as event parameters or custom dimensions.
For Pipedrive CRM integration, dataLayer injection lets you enrich GA4 events with CRM-side data that would otherwise never reach your analytics — deal stage, contact owner, deal value, pipeline name, or any other Pipedrive field your attribution model needs.
How Do You Configure GTM to Capture and Forward Pipedrive Data?
Follow these steps to build the GTM and dataLayer pipeline:
Step 1 — Define your dataLayer push structure
Establish a consistent data schema for the objects you’ll push into the dataLayer. Consistency matters because GTM variables reference specific key names — changing the schema later breaks your tags.
javascript
// Standard Pipedrive dataLayer push structure
window.dataLayer = window.dataLayer || [];
window.dataLayer.push({
event: 'pipedrive_deal_updated',
pipedrive: {
contact_id: '12345',
deal_id: '67890',
deal_stage: 'Proposal Sent',
deal_value: 15000,
pipeline_name: 'Enterprise Sales',
deal_owner: 'jane.smith@company.com',
deal_currency: 'USD'
}
});
Step 2 — Create GTM Data Layer Variables
In your GTM container, create a Data Layer Variable for each Pipedrive field you want to pass to GA4:
| Variable Name | Data Layer Key | Use in GA4 |
|---|---|---|
| DLV – Pipedrive Contact ID | pipedrive.contact_id | Custom dimension: pipedrive_contact_id |
| DLV – Deal Stage | pipedrive.deal_stage | Custom dimension: deal_stage |
| DLV – Deal Value | pipedrive.deal_value | Custom metric: deal_value |
| DLV – Pipeline Name | pipedrive.pipeline_name | Custom dimension: pipeline_name |
| DLV – Deal Owner | pipedrive.deal_owner | Custom dimension: deal_owner |
Step 3 — Create a GTM trigger for the Pipedrive event
Build a Custom Event trigger in GTM that fires on pipedrive_deal_updated (or whichever event name you defined in your dataLayer push). This trigger activates your GA4 event tag when new Pipedrive data arrives.
Step 4 — Configure the GA4 Event tag
Create a GA4 Event tag in GTM triggered by your Pipedrive custom event. Map each GTM Data Layer Variable to a GA4 event parameter:
- Event name:
crm_deal_updated - Parameters:
pipedrive_contact_id,deal_stage,deal_value,pipeline_name,deal_owner
Step 5 — Register custom dimensions in GA4
Navigate to GA4 Admin → Custom Definitions → Custom Dimensions and register each parameter you’re passing from GTM. Without this registration step, GA4 receives the parameters but doesn’t surface them in reports or make them available for audience building.
How Do You Trigger dataLayer Pushes From Pipedrive Webhook Events?
Pipedrive CRM supports webhooks that fire on specific events — deal stage changes, deal creation, deal won/lost — making it possible to push CRM data to your website’s dataLayer in near real-time.
Here’s the architecture:
- Configure a Pipedrive webhook in Settings → Webhooks for the events you want to track (e.g.,
deal.updated,deal.added) - Build a webhook receiver endpoint on your server that accepts Pipedrive’s POST payload
- Validate the webhook payload and extract the relevant deal fields
- Push data to the relevant user session using a real-time mechanism — WebSockets, server-sent events, or a session-tagged dataLayer push on the user’s next page load
- Trigger the GTM dataLayer push that carries the Pipedrive data into GA4
For server-side implementations, consider using Google Tag Manager’s Server-Side container, which lets you process Pipedrive webhook payloads directly and forward structured events to GA4 without requiring a browser-side dataLayer push at all.
How Do You Unify Pipedrive CRM and GA4 User Identities?
What Is GA4 User-ID and Why Does It Matter for CRM Integration?
GA4’s User-ID feature allows you to assign a consistent identifier to a user across multiple sessions, devices, and browsers. By default, GA4 identifies users through anonymous client IDs stored in cookies — which reset when cookies clear and don’t persist across devices.
When you integrate Pipedrive CRM with GA4 using User-ID, you replace or supplement the anonymous client ID with your Pipedrive contact ID. This creates a persistent, cross-session identity that connects a user’s entire behavioral history — across multiple visits, devices, and months — to a single Pipedrive contact record.
According to Google’s official GA4 documentation, User-ID data populates the User Explorer report, enabling session-level analysis for individual identified users — a capability with direct sales intelligence applications.
How Do You Implement GA4 User-ID Using Pipedrive Contact IDs?
Step 1 — Set User-ID at authentication or form submission
Whenever a visitor identifies themselves — by submitting a form, logging in, or clicking a tracked email link — call gtag('config') with their Pipedrive contact ID as the user_id parameter:
javascript
// Set GA4 User-ID to Pipedrive contact ID
gtag('config', 'G-XXXXXXXXXX', {
user_id: pipedriveContactId.toString()
});
Step 2 — Persist the contact ID in a first-party cookie
Store the Pipedrive contact ID in a first-party cookie so it persists across subsequent sessions and sets User-ID automatically on return visits — even before the user re-identifies themselves:
javascript
// Set a first-party cookie with the Pipedrive contact ID
document.cookie = `pipedrive_cid=${pipedriveContactId}; max-age=31536000; path=/; SameSite=Lax`;
// On subsequent page loads, read the cookie and set User-ID
const pipedriveId = document.cookie.match(/pipedrive_cid=([^;]+)/)?.[1];
if (pipedriveId) {
gtag('config', 'G-XXXXXXXXXX', { user_id: pipedriveId });
}
tep 3 — Pass contact IDs through email links for returning contacts
When your team sends emails from Pipedrive CRM or through connected email tools, append the Pipedrive contact ID as a URL parameter on any website links:
https://yoursite.com/proposal?pipedrive_cid=12345&utm_source=crm&utm_medium=email
On the landing page, read the pipedrive_cid parameter and use it to set User-ID and populate the cookie — re-identifying a returning contact without requiring them to fill out a form again.
How Do You Join Pipedrive Deal Data With GA4 Behavioral Data for Reporting?
User-ID unification creates the identifier linkage. To actually report on the combined dataset, you need a data join layer. The most scalable approach uses BigQuery:
- Enable GA4 BigQuery export — GA4 Admin → BigQuery Linking → connect your Google Cloud project. GA4 exports raw event data including User-ID daily.
- Export Pipedrive data to BigQuery — use the Pipedrive API to pull deal, contact, and activity data on a scheduled basis, or use a native connector like Stitch, Fivetran, or Airbyte.
- Join on the shared User-ID / contact ID — write a SQL query that joins the GA4 events table with the Pipedrive contacts table on
user_id = pipedrive_contact_id. - Build attribution reports in Looker Studio — connect your BigQuery joined dataset to Looker Studio (formerly Google Data Studio) and build dashboards that show deal value by traffic source, pipeline stage by campaign, and closed-won revenue by marketing channel.
Conclusion: What Does a Fully Integrated Pipedrive and GA4 Stack Give Your Business?
Connecting Pipedrive CRM to Google Analytics 4 through API-driven contact ID passing, GTM dataLayer injection, and GA4 User-ID unification gives your business something most competitors don’t have: a complete, joined view of the customer journey from first ad impression to closed deal.
Specifically, a fully integrated stack enables:
- True revenue attribution — know which campaigns, keywords, and content pieces generate deals that actually close, not just leads that enter the funnel
- Smarter budget allocation — shift ad spend toward channels that produce high-value Pipedrive deals rather than optimizing for cost-per-lead alone
- Sales and marketing alignment — give both teams a shared dataset that ends attribution debates and replaces opinion with evidence
- Behavioral context for reps — surface which pages a contact visited, which content they consumed, and which offers they engaged with before their first sales call
- CRM-informed audiences — push Pipedrive deal stage segments back into Google Ads for precise retargeting of contacts at specific pipeline stages
The technical implementation requires investment — a developer comfortable with APIs, GTM, and basic JavaScript will handle the core setup in one to three days. However, the attribution clarity that follows compounds in value every month, as your data accumulates and your team makes sharper decisions faster.
Pipedrive CRM provides the API infrastructure, webhook system, and custom field flexibility to support this integration fully. Start with UTM + contact ID passing as the foundational layer, add GTM dataLayer injection for richer event data, and implement User-ID unification to complete the picture. Each layer independently improves your attribution — together, they give you a revenue intelligence stack that most businesses don’t build until they’re far larger.
Frequently Asked Questions
The core integration — contact ID passing and basic dataLayer injection — runs entirely client-side without a server-side GTM container. However, server-side GTM significantly improves the implementation in two key ways: it removes your tracking from browser-based ad blockers and privacy extensions that block client-side GA4 tags, and it lets you process Pipedrive CRM webhook payloads directly without requiring a browser-side dataLayer push. For businesses where tracking coverage and data completeness matter significantly — typically those running high-volume paid campaigns — server-side GTM is worth the additional setup. For smaller implementations focused on lead quality analysis rather than pixel-perfect attribution, a well-implemented client-side setup delivers strong results. Start client-side and migrate specific tags server-side as your data needs mature.
Passing Pipedrive CRM contact IDs to GA4 qualifies as processing personal data under GDPR and CCPA definitions, since you’re creating a link between a behavioral profile and an identified individual. This means you must obtain explicit user consent before setting User-ID or passing contact identifiers to GA4 — your cookie consent mechanism must specifically cover CRM-linked analytics, not just standard GA4 tracking. Additionally, your privacy policy must disclose that you connect CRM identity data with analytics data and explain the purpose. GA4’s User-ID feature includes a hashing option that lets you transmit pseudonymized identifiers rather than raw contact IDs — use this in production. Consult a qualified privacy counsel familiar with your operating jurisdictions before deploying this integration in markets governed by GDPR, and implement consent-gated firing in GTM so CRM-linked events only fire after explicit consent is captured.

