Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Google Tag Assistant Legacy Error: Number field should not be quoted: 'transactionTotal' , 'transactionTax' and 'transactionShipping' #35

Open
shashidharkumar opened this issue Feb 16, 2023 · 3 comments

Comments

@shashidharkumar
Copy link

shashidharkumar commented Feb 16, 2023

In Tag Assistant Google it is tracking three error on success page as
Number field should not be quoted: 'transactionTotal'
Number field should not be quoted: 'transactionTax'
Number field should not be quoted: 'transactionShipping'

How to fix this?

@shashidharkumar shashidharkumar changed the title Number field should not be quoted: 'transactionTotal' , 'transactionTax' and 'transactionShipping' Google Tag Assistant Legacy Error: Number field should not be quoted: 'transactionTotal' , 'transactionTax' and 'transactionShipping' Feb 16, 2023
@olivierognn
Copy link

olivierognn commented May 2, 2023

I see the same issue on success page.
Schermata 2023-05-02 alle 13 30 57
adding a float cast to \MagePal_GoogleTagManager_Block_Tm::getOrdersTrackingCode
should fix the error


$transaction = array(
                'transactionId' => $order->getIncrementId(),
                'transactionAffiliation' => Mage::app()->getStore()->getFrontendName(),
                'transactionTotal' => (float)$order->getBaseGrandTotal(),
                'transactionTax' => (float)$order->getBaseTaxAmount(),
                'transactionShipping' => (float)$order->getBaseShippingAmount(),
                'discountCode' => $order->getCouponCode(),
                'discountPrice' => $order->getDiscountAmount(),
                'transactionProducts' => $product
            );

@czamorasoft
Copy link

czamorasoft commented May 11, 2023

Hey @shashidharkumar and @olivierognn , I think that the error can be solved easily using the JSON Constant "JSON_NUMERIC_CHECK".

In /app/code/local/MagePal/GoogleTagManager/etc/Tm.php on line 84 changed from:

$result[] = sprintf("dataLayer.push(%s);", json_encode($transaction));

to:

$result[] = sprintf("dataLayer.push(%s);", json_encode($transaction, JSON_NUMERIC_CHECK));

Solved 100% to me.

Reference: https://www.php.net/manual/en/json.constants.php

image

@czamorasoft
Copy link

#37

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants