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

Item categories have different & signs on view_item and view_item_list #357

Open
joeprongen opened this issue Jul 1, 2024 · 7 comments
Open

Comments

@joeprongen
Copy link

We have some product categories with a & sign in them, but for some reason the view_item_list and view_item events show them differently, which is affecting our tracking of these categories.

VIEW ITEM LIST

currency: "EUR",
value: 3332,
items: [
  {
    item_id: 892548,
    item_name: "Modular Egg Workspace met kast inclusief Big Gree" +
               "n Egg Large",
    sku: "6017429198120",
    price: "3332.00",
    stocklevel: 10,
    stockstatus: "instock",
    google_business_vertical: "retail",
    item_category: "Buitenkeuken & tafels",
    item_category2: "Big Green Egg Modular Outdoor Workspace",
    id: 892548,
    item_brand: "",
    item_list_name: "Algemeen product lijst",
    index: 2,
    product_type: "simple"
  },

VIEW ITEM
ecommerce: {
currency: "EUR",
value: 3332,
items: [
{
item_id: 892548,
item_name: "Modular Egg Workspace met kast inclusief Big Gree" +
"n Egg Large",
sku: "6017429198120",
price: 3332,
stocklevel: 10,
stockstatus: "instock",
google_business_vertical: "retail",
item_category: "Buitenkeuken & tafels",
item_category2: "Big Green Egg Modular Outdoor Workspace",
id: 892548,
item_brand: ""
}
]
}

We cant seem to find the reasons this is going wrong, it all seems the same function.
Do you have any idea? Or can you reproduce it?

@Remcospruijt
Copy link

Scherm_afbeelding 2024-07-01 om 08 40 06

I Would like to add in on this issue. Here is a screenshot of the issue with the received data. Here you can see that the item_category includes & instead of the & that is inserted in the sent data

@Remcospruijt
Copy link

@duracelltomi Could you please help us with this issue?

@duracelltomi
Copy link
Owner

Hi,

Sorry, I was on vacation.
Could you post the URL of this website?

Data in view_item is encoded to a JavaScript object using the json_encode PHP function which creates this output.
Since I am not aware of any flag that could change this behavior, probably one solution could be to do a simple search&replace in the code of GTM4WP.

@Remcospruijt
Copy link

@duracelltomi No problem! Hope you had a good one

An example page ; https://www.bbqexperiencecenter.nl/modular-egg-workspace-met-kast-inclusief-big-green-egg-lar/
When searching for item_category in the page source you can see the &

@joeprongen
Copy link
Author

hi @duracelltomi

Did you have any chance to look into this already?

Thanks in advance

@duracelltomi
Copy link
Owner

I did some testing recently but I am not sure this can be fixed in all places.

For example on single product pages, product data is stored in an input node's value parameter. To make the code safe, I need to route the value through esc_attr() which will always encode & even if I revert back the encoding after calling json_encode.

Revering back what esc_attr() returns will trigger signals in security checks.

@Remcospruijt
Copy link

Hmm alright.. I understand the issue. Unfortunately this issue is giving us different information on the pages, so it's quite annoying for us.

Couldn't you push the data with JS and parse it there? Could also become a filter to avoid problems in other scenario's

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