• Guest, before posting your code please take these rules into consideration:
    • It is required to use our BBCode feature to display your code. While within the editor click < / > or >_ and place your code within the BB Code prompt. This helps others with finding a solution by making it easier to read and easier to copy.
    • Don't share a wall of code. All we want is the problem area, the code related to your issue.


    To learn more about how to use our BBCode feature, please click here.

    Thank you, Code Forum.

Help with pulling in product details

bbop2282

New Coder
Hi!
I am not a developer or programmer but am rather in the marketing realm. I'm working on implementing some tracking for an e-commerce website, and I'd like to add to the script I have so that way the product details (pricing, name, id) get pulled in with the tracking. I know this is a fairly easy thing to accomplish, but I need to guidance! The script as-is is correctly tracking events, so it is just adding in this supplemental information.

Code:
<script type = "text/javascript">
   var vendor = window.vendor || [];
   vendor.track("Added To Cart", {{Add to Cart}});
</script>

I believe I'd need to add something like the below, but can you explain to me what I'd put after the equal sign and why?
Code:
<script type = "text/javascript">
   var vendor = window.vendor || [];
    item['productRating']
        item['name'] =
        item['price'] =
        item['quantity'] =
        item['cartItemId'] =
        item['productId'] =
        item['name'] =
        item['category'] =
   vendor.track("Added To Cart", {{Add to Cart}});
</script>

Editing to also add another script that I'm trying to do the same thing on:

Code:
<script type="text/javascript">
    var vendor = window.klaviyo || [];
    var orderedItems = window.GEE_cartproducts;
    vendor.track("Placed Order", orderedItems);
</script>

I know the information is there are well (see screenshot) so I just need it to dynamically fill it based on the product!
Thank you so much for your help! Hopefully, I posted this in the correct forum category.
 

Attachments

  • screenshot of datalayer.jpg
    screenshot of datalayer.jpg
    9.2 KB · Views: 2
Last edited:
Top Bottom