Welcome!

By registering with us, you'll be able to discuss, share and private message with other members of our community.

SignUp Now!
  • 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.
    • You can also use markdown to share your code. When using markdown your code will be automatically converted to BBCode. For help with markdown check out the markdown guide.
    • 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: 3
Last edited:
I think you need quotes inside that object {{Add to Cart}}.
I also know item['productRating']['name'] or only item['name'] should be.
Try like item['property name'] = (object getting data from)[0].(property by name) for that.
You could also maybe combine scripts into one large script if you like wanted.
X E.
 

New Threads

Latest posts

Buy us a coffee!

Back
Top Bottom