Want to import offline conversions into Google Ads but don’t have a CRM? Here’s how to do it with just Google Tag Manager, Google Sheets, and Apps Script.
The Setup Overview
- Capture UTM params and click IDs (gclid, fbclid, etc.) on your site
- Send them to a Google Sheet via a webhook
- Pull that data into your Google Ads Offline Conversion Tracking (OCT) sheet
- Filter by lead status and import to Google Ads
Step 1: Capture Tracking Params with GTM
This script grabs UTM parameters and click IDs from the URL, stores them in cookies (90-day expiry), and keeps them persistent across pages.
<script>
(function() {
var cookieDays = 90;
var trackingParams = ['utm_source','utm_medium','utm_campaign','utm_term','utm_content','gclid','gbraid','wbraid','fbclid','ttclid','msclkid'];
function setCookie(name, value, days) {
var date = new Date();
date.setTime(date.getTime() + (days * 24 * 60 * 60 * 1000));
document.cookie = name + '=' + encodeURIComponent(value) + '; expires=' + date.toUTCString() + '; path=/';
}
function getCookie(name) {
var match = document.cookie.match(new RegExp('(?:^|;\\s*)' + name + '=([^;]*)'));
return match ? decodeURIComponent(match[1]) : null;
}
var url = new URL(window.location.href);
trackingParams.forEach(function(param) {
var value = url.searchParams.get(param);
if (value) setCookie(param, value, cookieDays);
});
var currentParams = new URLSearchParams(window.location.search);
var changed = false;
trackingParams.forEach(function(param) {
if (!currentParams.has(param)) {
var cookieValue = getCookie(param);
if (cookieValue) {
currentParams.set(param, cookieValue);
changed = true;
}
}
});
if (changed) {
var queryString = currentParams.toString();
var newUrl = window.location.pathname + (queryString ? '?' + queryString : '') + window.location.hash;
history.replaceState({}, '', newUrl);
}
window.dataLayer = window.dataLayer || [];
window.dataLayer.push({
event: 'tracking_params_loaded',
utm_source: getCookie('utm_source') || '',
utm_medium: getCookie('utm_medium') || '',
utm_campaign: getCookie('utm_campaign') || '',
utm_term: getCookie('utm_term') || '',
utm_content: getCookie('utm_content') || '',
gclid: getCookie('gclid') || '',
gbraid: getCookie('gbraid') || '',
wbraid: getCookie('wbraid') || '',
fbclid: getCookie('fbclid') || '',
ttclid: getCookie('ttclid') || '',
msclkid: getCookie('msclkid') || ''
});
})();
</script>
JavaScriptStep 2: Create Cookie Variables in GTM
Here are Custom JavaScript Variables for each — create one GTM variable per param, name them clearly (e.g. CJS - UTM Campaign Decoded):
UTM Campaign
javascript
function() {
var match = document.cookie.match(/(?:^|;\s*)utm_campaign=([^;]*)/);
return match ? decodeURIComponent(match[1]) : undefined;
}JavaScriptUTM Content
javascript
function() {
var match = document.cookie.match(/(?:^|;\s*)utm_content=([^;]*)/);
return match ? decodeURIComponent(match[1]) : undefined;
}JavaScriptUTM Term
javascript
function() {
var match = document.cookie.match(/(?:^|;\s*)utm_term=([^;]*)/);
return match ? decodeURIComponent(match[1]) : undefined;
}JavaScriptUTM Source
javascript
function() {
var match = document.cookie.match(/(?:^|;\s*)utm_source=([^;]*)/);
return match ? decodeURIComponent(match[1]) : undefined;
}JavaScriptUTM Medium
javascript
function() {
var match = document.cookie.match(/(?:^|;\s*)utm_medium=([^;]*)/);
return match ? decodeURIComponent(match[1]) : undefined;
}JavaScriptGCLID
javascript
function() {
var match = document.cookie.match(/(?:^|;\s*)gclid=([^;]*)/);
return match ? decodeURIComponent(match[1]) : undefined;
}JavaScriptGBRAID
javascript
function() {
var match = document.cookie.match(/(?:^|;\s*)gbraid=([^;]*)/);
return match ? decodeURIComponent(match[1]) : undefined;
}JavaScriptWBRAID
javascript
function() {
var match = document.cookie.match(/(?:^|;\s*)wbraid=([^;]*)/);
return match ? decodeURIComponent(match[1]) : undefined;
}JavaScriptFBCLID
javascript
function() {
var match = document.cookie.match(/(?:^|;\s*)fbclid=([^;]*)/);
return match ? decodeURIComponent(match[1]) : undefined;
}JavaScriptTTCLID
javascript
function() {
var match = document.cookie.match(/(?:^|;\s*)ttclid=([^;]*)/);
return match ? decodeURIComponent(match[1]) : undefined;
}JavaScriptMSCLKID
javascript
function() {
var match = document.cookie.match(/(?:^|;\s*)msclkid=([^;]*)/);
return match ? decodeURIComponent(match[1]) : undefined;
}JavaScriptStep 3: Send Data to Google Sheets via Apps Script
Create a new Google Sheet, open Extensions → Apps Script, and paste this:
function doGet(e) {
e = e || { parameter: { test: "manual_run" } };
var spreadsheet = SpreadsheetApp.getActiveSpreadsheet();
var sheet = spreadsheet.getActiveSheet();
var timestamp = Utilities.formatDate(new Date(), "GMT+05:00", "yyyy-MM-dd HH:mm:ssXXX");
var params = e.parameter;
var headers = [];
var lastColumn = sheet.getLastColumn();
if (lastColumn > 0) {
headers = sheet.getRange(1, 1, 1, lastColumn).getValues()[0];
}
if (headers.length === 0 || headers[0] !== "Timestamp") {
headers.unshift("Timestamp");
sheet.getRange(1, 1).setValue("Timestamp");
}
var newRow = [];
newRow[0] = timestamp;
for (var key in params) {
if (headers.indexOf(key) === -1) {
headers.push(key);
sheet.getRange(1, headers.length).setValue(key);
}
newRow[headers.indexOf(key)] = params[key];
}
sheet.appendRow(newRow);
return ContentService.createTextOutput("Data added successfully");
}
JavaScriptDeploy it as a Web App (Execute as: Me, Access: Anyone). You’ll get a URL like:
https://script.google.com/macros/s/YOUR_SCRIPT_ID/exec
JavaScriptStep 4: Fire the Webhook from GTM
Create a Custom HTML tag (or Image tag) that calls this URL whenever your lead event fires, pulling values from your cookie variables:
https://script.google.com/macros/s/YOUR_SCRIPT_ID/exec?utm_source={{Cookie - UTM Source}}&utm_medium={{Cookie - UTM Medium}}&utm_campaign={{Cookie - UTM Campaign}}&utm_term={{Cookie - UTM Term}}&utm_content={{Cookie - UTM Content}}&gclid={{Cookie - GCLID}}&gbraid={{Cookie - GBRAID}}&wbraid={{Cookie - WBRAID}}&fbclid={{Cookie - FBCLID}}&ttclid={{Cookie - TTCLID}}&msclkid={{Cookie - MSCLKID}}
JavaScriptEvery time this fires, a new row gets added to your sheet with the timestamp and all tracking data — no CRM needed.
Step 5: Pull Lead Data into Your CRM/Tracking Sheet
If you’re tracking leads from multiple channels (like WhatsApp) in a separate sheet, pull specific columns using IMPORTRANGE:
=IMPORTRANGE("https://docs.google.com/spreadsheets/d/YOUR_SHEET_ID/edit", "Sheet1!A:A")
JavaScriptStep 6: Filter Only Qualified Leads
In your offline conversion sheet, filter rows where status is “Lead” before pulling them in:
=ARRAYFORMULA(
IFERROR(
FILTER(
IMPORTRANGE("YOUR_SHEET_ID","Whatsapp!C2:C"),
IMPORTRANGE("YOUR_SHEET_ID","Whatsapp!A2:A")="Lead"
),
""
)
)
JavaScriptRepeat this formula for each column you need (GCLID, conversion name, conversion value, currency, etc.), just changing the column letter:
=ARRAYFORMULA(
IFERROR(
FILTER(
IMPORTRANGE("YOUR_SHEET_ID","Whatsapp!B2:B"),
IMPORTRANGE("YOUR_SHEET_ID","Whatsapp!A2:A")="Lead"
),
""
)
)
JavaScriptFor static fields like Conversion Name or Currency, just check if the row has a value:
=ARRAYFORMULA(IF(A8:A="", "", "Whatsapp offline"))JavaScriptStep 7: Use Google’s Official OCT Template
Copy Google’s official Offline Conversion Import template (Google Click ID version):
Google Ads Conversion Import Template
This template handles the formatting Google Ads expects: GCLID, Conversion Name, Conversion Time, Conversion Value, Currency Code.
Make sure your conversion timestamps match the correct timezone using Google’s timezone reference sheet:
Step 8: Connect the Sheet to Google Ads
- In Google Ads, go to Tools → Conversions → Uploads
- Link your Google Sheet as the data source
- Set the upload schedule (hourly, daily, etc.)
- Map your sheet columns to GCLID, Conversion Name, Time, Value, and Currency
Google Ads will automatically pull new rows and import them as offline conversions tied to the original click.
Why This Works Without a CRM
- The GTM script captures and persists click IDs across sessions using cookies
- Apps Script acts as your “database” — completely free
- IMPORTRANGE lets you connect multiple sheets (lead sources) without manual exports
- Google’s official OCT template ensures the data format matches what Google Ads expects
Cost Breakdown
- Google Tag Manager: Free
- Google Sheets: Free
- Apps Script: Free (within Google’s quota limits)
- Google Ads OCT: Free (built into your existing Ads account)
Total: $0/month
Quick Notes
Apps Script Quotas: Free tier allows enough requests for most small-to-mid traffic sites. Check Google’s quota limits if you’re getting high volume.
GCLID Expiry: Google Ads typically accepts conversions within 90 days of the click, matching the cookie expiry used in the script above.
Manual Status Updates: Since there’s no CRM, you’ll need to manually update lead status (Lead, Won, Lost) in the sheet for the filters to work.
That’s the full loop — from capturing the click to importing the conversion back into Google Ads, without spending a dollar on additional tools.

0 Comments