WordPress.org

Forums

DuracellTomi's Google Tag Manager for WordPress
[resolved] Getting this Suggestion: Data layer fields should be quoted (6 posts)

  1. miherbal
    Member
    Posted 1 year ago #

    Hello,

    I am getting this information from Google Chrome Tag Assistant Plugin

    Suggestion: Data layer fields should be quoted

    Some tags are working while others are not I don't get it.

    I am also using another plugin called
    Google Analyticator

    And I am not sure if this is causing the problem I deactivated it and still was not working.

    I have the php code set to custom and installed where requested.

    I added a tag for 7search and could not validate the conversion tracking code. Some of the other tags work like doctor trusted.

    http://michiganherbalremedies.com/cart/order-received

    this page should be firing several tags and passing conversion data but it does not.

    Thoughts?

    Thank you.

    Jeff

    https://wordpress.org/plugins/duracelltomi-google-tag-manager/

  2. mediakov
    Member
    Posted 1 year ago #

    sorry, wrong topic

  3. mediakov
    Member
    Posted 1 year ago #

    I have the same issue. On my site, it looks like the problem is in "ecomm_totalvalue":value. As soon as i know, the value should be quoted, like this: "ecomm_totalvalue":"value".

  4. duracelltomi
    Member
    Plugin Author

    Posted 1 year ago #

    Hi Jeff,

    You are getting a false positive error. Tag Assistant parses the add-to-cart event JS code. It includes unquoted parameters that can not be quoted since it would break the code.

    Regarding the second question: it is hard to tell you what could be the reason. If you are open to give me read only access to your GTM account please contact me using the contact form of duracelltomi.com

    @mediakov: I do not think this is the reason but we will see.

    Cheers,
    Thomas Geiger

  5. Chirag Vora
    Member
    Posted 1 year ago #

    Unquoted parameters cannot be quoted since it would break the code.

    But google says that if you have any other character apart from alpha numeric and underscores you may run into problems.
    Also you cannot use reserved words like function...

    Quoted from: https://support.google.com/tagassistant/answer/3207128?hl=en&ref_topic=2947092#dl_quoted

    Data layer fields should be quoted

    While quotes are not strictly required for variable names that consist of only letters, numbers, and underscores, and which are not reserved words (e.g. function, export, native, etc.), to avoid issues, it"s recommended that all variable names be enclosed in quotes. Examples: dataLayer.push({new-variable: "value"}); // Won"t work dataLayer.push({"new-variable": "value"}); // Better

    I often use hiphen and colon in product names, should it affect my tags in any way?

    Thanks for the plugin!

  6. duracelltomi
    Member
    Plugin Author

    Posted 1 year ago #

    Every variable name in my plugin is quoted however if you enable WooCommerce integration for example there will be some added code that assigns values to those variables dynamically.

    I can not quote a JavaScript code since it would not execute when quoted:

    'productSKU': $( this ).data( 'product_sku' )

    I can not quote the value since it is a function call but Tag Assistant parses this line as well and reports a "Suggestion" warning.

    Some datalayer variables are integer values that does not need to be quoted. In my experience when a datalayer variable name is quoted but the integer value is not, Tag Assistant does not report any issue. Hyphens and colons should not be a problem since they are escaped while adding them to the datalayer.

Topic Closed

This topic has been closed to new replies.

About this Plugin

  • DuracellTomi's Google Tag Manager for WordPress
  • Frequently Asked Questions
  • Support Threads
  • Reviews

About this Topic

Tags

No tags yet.