On this page
What this issue is
The dataLayer is a JavaScript list on your page (window.dataLayer) where your site passes information, such as product prices and order totals, to Google Tag Manager (GTM). Each value has a type: a number, a piece of text (string), true/false, and so on.
This issue happens when a field that should be a number arrives as text. "value": 49 is a number. "value": "49.00" and "value": "$49.00" are strings. Quantity, price, value and shipping are the usual offenders.
// Wrong: strings
window.dataLayer.push({
event: 'purchase',
ecommerce: {
transaction_id: 'T-1001',
value: '$1,299.50',
currency: 'USD',
items: [{ item_id: 'SKU-1', price: '1299.50', quantity: '1' }]
}
});
// Right: numbers
window.dataLayer.push({
event: 'purchase',
ecommerce: {
transaction_id: 'T-1001',
value: 1299.50,
currency: 'USD',
items: [{ item_id: 'SKU-1', price: 1299.50, quantity: 1 }]
}
});Why it costs you leads or sales
Revenue data drives reporting and ad bidding. If a platform cannot read the value as a number, the conversion may be recorded with no value, a value of 0, or a wrong value. Currency symbols and thousands separators are common causes: "1,299.50" may be read as 1.
The sale itself still happens, so nobody notices. But reports understate revenue, ROAS (return on ad spend) looks worse than it is, and value-based bidding in Google Ads or Meta learns from bad numbers. That is why the impact is medium rather than critical: orders are not lost, but decisions are made on wrong data.
Example: five orders worth $1,000 in total. Values with a comma or symbol are read wrongly, so the platform reports far less.
- Customer buysOrder total $1,299.50
- dataLayer pushvalue sent as "$1,299.50" (string)
- GTM tagsPass the text value on
- GA4 / Ads / MetaValue missing, 0 or wrong
The purchase happens, but the value is damaged on the way to your reports.
How to check if your site has it
Open the page after an action
Go to a product page, cart or order confirmation (use a test order or test mode where you can).
Inspect the dataLayer in the console
Open browser DevTools, then the Console, and run the snippet below. It lists any ecommerce number fields that are strings.
Use GTM PreviewGoogle Tag Manager
In Tag Assistant (GTM Preview), click the purchase or add_to_cart event, open the Data Layer tab and look at the values. Strings appear in quotes; numbers do not.
Check GA4 DebugView
In GA4, Admin, DebugView, open the event and confirm value and price show as numbers with the right currency.
window.dataLayer.forEach(function (e) {
var ec = e.ecommerce;
if (!ec) return;
['value','shipping','tax'].forEach(function (k) {
if (k in ec && typeof ec[k] !== 'number') console.warn(e.event, k, typeof ec[k], ec[k]);
});
(ec.items || []).forEach(function (i) {
['price','quantity','discount'].forEach(function (k) {
if (k in i && typeof i[k] !== 'number') console.warn(e.event, 'item.' + k, typeof i[k], i[k]);
});
});
});How to fix it
The best fix is at the source: push numbers. If you cannot change the source quickly, convert the value in GTM. Which route you take depends on your platform or theme.
Strip symbols and convert
Before pushing, remove currency symbols and thousands separators, then use parseFloat. Use Number() for quantity.
Round sensibly
Use Math.round(x * 100) / 100 to avoid long decimals.
Find where the push is made
Check your analytics or GTM plugin settings and your theme files for dataLayer.push. Do not use formatted price functions such as wc_price() for values; use the raw number from the order or product object.
Update the plugin or template
Update the plugin, or output the raw value with a float cast, for example (float) $order->get_total().
Avoid formatted money in the push
In theme code, output price with the money filters only for display. For the dataLayer use a raw number, for example {{ product.price | divided_by: 100.0 }}, because Shopify prices are in cents.
Do not wrap in quotes
Make sure the Liquid output is not inside quotation marks in the push.
Create a Custom JavaScript variable
Variables, New, Custom JavaScript. Read the Data Layer Variable and return a clean number (code below).
Use it in your tags
Replace the raw variable with the new one in your GA4, Google Ads and Meta tags, then test in Preview.
Check custom code and Ecommerce scripts
If you build the push in custom code, read prices from a numeric source or strip symbols and convert as in the Custom code tab.
Review custom tracking code
If a funnel step pushes a value you typed or read from the page text, make sure it is a bare number, not text like "$97".
function () {
var raw = {{DLV - ecommerce.value}};
if (typeof raw === 'number') return raw;
if (raw == null) return undefined;
var cleaned = String(raw).replace(/[^0-9.\-]/g, '');
var n = parseFloat(cleaned);
return isNaN(n) ? undefined : n;
}How to confirm it's fixed
- The console check prints no warnings for value, price or quantity.
- GTM Preview shows numbers without quotes in the Data Layer tab.
- GA4 DebugView shows the right value and currency on purchase.
- A test order total matches the value in GA4 and your ad platform after processing.
- Google Ads and Meta conversions show non-zero values.
Before
- value: "$1,299.50"
- Revenue missing, 0 or wrong
- Bidding learns from bad data
After
- value: 1299.50
- Revenue matches the order
- Reports and bidding use real numbers
How to prevent it happening again
- Write down a dataLayer spec: each field, its type and an example value.
- Never reuse display text (formatted prices) as tracking data.
- Re-test purchase and add_to_cart events after theme, plugin or checkout updates.
- Use a GTM clean-up variable as a safety net for key values.
- Check revenue in GA4 against your store or CRM totals each month.
How FunnelGuard handles this
FunnelGuard detects this issue. A robot visitor runs your real journey on a schedule, such as a checkout up to the point before payment, and checks the tracking data your site sends. Its dataLayer parameter rules look at the values in those events and flag fields that arrive with the wrong type, such as a price sent as a string.
If a check fails, it is re-checked from a second region before one alert goes out, with a screenshot and a likely cause. The Free plan covers 1 site and 2 journeys with daily checks and no card. Paid plans start with a 3-day free trial.
Questions people ask
Why is my GA4 purchase value showing 0 or wrong?
One common cause is that value is sent to the dataLayer as a string, such as "$49.00" or "1,299.50", instead of a number. Check the purchase event in GTM Preview or GA4 DebugView, and push plain numbers like 49.00.
Should price in the dataLayer be a string or a number?
A number. Fields such as value, price, quantity, tax and shipping should be numbers without currency symbols or thousands separators. The currency goes in a separate currency field, like "USD".
How do I convert a string price to a number in GTM?
Create a Custom JavaScript variable that reads your Data Layer Variable, removes everything except digits, dot and minus, and returns parseFloat of the result. Use this variable in your tags instead of the raw one. Fixing it at the source is still better.
How can I check the data type of a dataLayer variable?
In the browser console, run typeof on the field, for example typeof window.dataLayer[0].ecommerce.value. In GTM Preview's Data Layer tab, strings show in quotes and numbers do not.
Does a string quantity or price break Google Ads conversion value?
It can. If the platform cannot read the text as a number, the conversion may be recorded with no value or a wrong one. That affects reporting and value-based bidding.
Why does my Shopify dataLayer price look 100 times too big?
Shopify stores prices in cents in many Liquid objects. Divide by 100 (for example price | divided_by: 100.0) and output it without quotes so the dataLayer gets a proper number.
Can FunnelGuard detect a wrong data type in my dataLayer?
Yes. FunnelGuard runs your journeys on a schedule and applies dataLayer parameter rules to the events it sees, flagging values with the wrong type such as a string price. You then get an alert with a screenshot and a likely cause.
Related issues
- TRK-113Variables returning undefined (dataLayer key renamed)Fix guide
- TRK-114Lookup table variable missing a new page/productFix guide
- TRK-115Custom HTML tag throwing JavaScript errorFix guide
- TRK-122sGTM forwarding to GA4 broken while browser hit succeedsFix guide
- TRK-123sGTM forwarding to Meta CAPI brokenFix guide
- TRK-099GTM container snippet missingFix guide