Keeping default language for Product Titles in Custom Pixel events

Keeping default language for Product Titles in Custom Pixel events

Matei86
Excursionist
27 0 7

Hello Shopify community,

 

I am working with Shopify's Custom Pixel and have encountered a localization issue that I'm hoping to get some assistance with. Specifically, when I subscribe to the 'product_viewed' event, I've noticed that the event.data.productVariant.title value is automatically localized based on the user's locale. For example, if a user is on the Italian locale, the product name is returned in Italian.

 

Here is a snippet of the code I am using:

 
analytics.subscribe('product_viewed', (event) => {
  const productPrice = event.data.productVariant.price.amount;
  const productTitle = event.data.productVariant.title;

  const payload = {
    event_name: event.name,
    event_data: {
      productPrice: productPrice,
      productTitle: productTitle,
    },
  };
  // ... rest of the code to handle the event
});
 

My store's default language is Romanian and for consistency in my analytics, I need the product titles to always be in Romanian, regardless of the user's current locale.

Is there an API or a command that can be used to ensure that the product titles are always returned in the store's default language, rather than being localized?

 

Thank you in advance for your help!

Replies 3 (3)

Small_Task_Help
Shopify Partner
1053 45 101

Hi,

 

Use Shopify's storefront API to fetch product data in Romanian

 

Query example

{
  productByHandle(handle: "your-product-handle") {
    title
    variants(first: 10) {
      edges {
        node {
          title
        }
      }
    }
  }
}

 

 

To Get Shopify Experts Help, Click Here or E-mail - hi@ecommercesmalltask.com
About Us - We are Shopify Expert India
At Google My Business - Ecommerce Small Task - Hire Shopify Developers Ahmedabad
Matei86
Excursionist
27 0 7

I just found out that there is a property called untranslatedTitle which can be used, thank you.

Small_Task_Help
Shopify Partner
1053 45 101

If you find difficulty in coding you can go for a paid Shopify developer 

To Get Shopify Experts Help, Click Here or E-mail - hi@ecommercesmalltask.com
About Us - We are Shopify Expert India
At Google My Business - Ecommerce Small Task - Hire Shopify Developers Ahmedabad