Skip to content
FunnelGuard

Fix guide by FunnelsGuard

dataLayer price sent as a string: how to find and fix it

TRK-132Medium impactDetectedBy FunnelGuardPublished Updated
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 vs right dataLayer pushjavascript
// 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.

Reported vs real revenueExample numbers
Reported vs real revenue (example)Real revenue: 1,000 $; Reported (strings): 620 $03837671,000620Real revenueReported (strings)$

Example: five orders worth $1,000 in total. Values with a comma or symbol are read wrongly, so the platform reports far less.

Where the wrong type does damage
  1. Customer buysOrder total $1,299.50
  2. dataLayer pushvalue sent as "$1,299.50" (string)
  3. GTM tagsPass the text value on
  4. 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

Check your dataLayer types
  1. 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).

  2. 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.

  3. 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.

  4. Check GA4 DebugView

    In GA4, Admin, DebugView, open the event and confirm value and price show as numbers with the right currency.

Console check for string numbersjavascript
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.

Fix by platform
  1. Strip symbols and convert

    Before pushing, remove currency symbols and thousands separators, then use parseFloat. Use Number() for quantity.

  2. Round sensibly

    Use Math.round(x * 100) / 100 to avoid long decimals.

GTM Custom JavaScript variable: clean numberjavascript
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

Confirmation checklist
  • 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 and after

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

Prevention habits
  • 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.

Does FunnelGuard catch this?

Detected

FunnelGuard checks for this today.

How: dataLayer params rules.

Stop finding out from your customers

FunnelGuard runs your real forms and checkouts on a schedule, checks the tracking and the leads behind them, and alerts you once, with a screenshot. Try any paid plan free for 3 days.