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

How to Pass Product Name, SKU and Price to Meta Pixel and GTM/GA4? #852

Open
rplakas opened this issue Aug 29, 2023 · 3 comments
Open

How to Pass Product Name, SKU and Price to Meta Pixel and GTM/GA4? #852

rplakas opened this issue Aug 29, 2023 · 3 comments

Comments

@rplakas
Copy link

rplakas commented Aug 29, 2023

Does anyone know if its possible to pass the Product Name, SKU and Price to Meta Pixel to the Meta Pixel and GTM/GA4?

Where would I find the variable names? Here is my add-to-cart tracking code within the Buy Button.

    "DOMEvents": {
'click .shopify-buy__btn-wrapper .shopify-buy__btn': function (evt, target) {
   fbq('track', 'AddToCart', {
   content_name: prod_name, 
   content_ids: [prod_sku],
 	content_type: 'product',
 	value: prod_price,
 	currency: 'USD'
});
// Push the "add_to_cart" event data to the data layer
window.dataLayer.push({
  'event': 'add_to_cart',
  'ecommerce': {
    'add': {
      'items': [{
        'item_id': prod_sku,
        'item_name': prod_name,
        'price': prod_price,
        'currencyCode': 'USD'
@rplakas
Copy link
Author

rplakas commented Sep 20, 2023

I figured out to do this with Individual Buy Buttons, still don't have it working with Collection Code though.

Here it is in case someone else needs it:

`"DOMEvents": {
'click .shopify-buy__btn-wrapper .shopify-buy__btn': function (evt, target) {

var prod_name = ui.components.product[0].model.title;
var prod_qty = ui.components.product[0].selectedQuantity;
var prod_sku = ui.components.product[0].selectedVariant.sku;
var prod_price = ui.components.product[0].selectedVariant.price.amount;

fbq('track', 'AddToCart', {
content_name: prod_name,
content_id: prod_sku,
quantity: prod_qty,
content_type: 'product',
value: prod_price,
currency: 'USD'
});`

@rplakas
Copy link
Author

rplakas commented Sep 20, 2023

For whatever reason using

var prod_sku = ui.components.product[0].selectedVariant.title;

resulted in it passing "Default Title" instead of the actual product title.

@rplakas
Copy link
Author

rplakas commented Sep 20, 2023

Does anyone know how to get this to work for Collection Code?

Using var prod_sku = ui.components.collectiont[0].selectedVariant.sku

results in an error in the console

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

1 participant