Announcement

Collapse
No announcement yet.

Facebook Pixel setup for ProductID and Add to Cart

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    #16
    If you're www.harveymaps.co.uk then there is already an onclick in your cart code. So best put the following just before the return statement.
    Code:
    fbq('track', 'AddToCart', {content_ids:['<actinic:variable name="ProductReference" encoding="perl" selectable="false" />'], content_type: 'product'});
    Norman - www.drillpine.biz
    Edinburgh, U K / Bitez, Turkey

    Comment


      #17
      Or put this in the <form ...> tag in your Product Page layout.
      Code:
      onsubmit="fbq('track', 'AddToCart', {content_ids:['<actinic:variable name="ProductReference" encoding="perl" selectable="false" />'], content_type: 'product'}); return true;"
      Norman - www.drillpine.biz
      Edinburgh, U K / Bitez, Turkey

      Comment


        #18
        Hi Norman, yes, we are www.harveymaps.co.uk. I was just about to update you to say that I abandoned the onclick method as i couldn't get it to fire, and have implemented similar to the receipt solution you provided earlier, which seems to be working.

        But I may replace it with one of the code snippets above, thanks.

        It's a relief to see FB receiving the damned event data to be honest so i may just leave it alone now!

        Comment


          #19
          I tried the 'onsubmit' method but it didn't seem to trigger the event.

          I added your code snippet to the layout 'Customisable Product Layout'.

          Code:
          <form method="post" accept-charset="iso-8859-1" class="imageOnLeftTextWrappedAround" onsubmit="fbq('track', 'AddToCart', {content_ids:['<actinic:variable name="ProductRef" encoding="perl" selectable="false" />'], content_type: 'product'}); return true;" action="<actinic:variable name="OnlineScriptURL" value="Shopping Cart Script URL" />" novalidate >
          I assume I am missing something but not sure what. For now, I have returned to the previous receipt page method for the cart which is working.

          Though, i assume for the Add to Cart event, the receipt page method is not ideal, as it returns each item in the cart every time the event is triggered by the same customer (so, 'product 1' for the first button click, then browse the store, add another item, and the FB event returns 'product 1' and 'product 2')

          Your button method would be preferable i think if I could get it to fire.

          Comment


            #20
            It looks like ProductRef is intended for use by the Cart Perl scripts. Use ProductReference instead. I've amended my post #17 to reflect this.
            And you can test it with:
            Code:
            onsubmit="alert('<actinic:variable name="ProductReference" />'); return true;"
            Norman - www.drillpine.biz
            Edinburgh, U K / Bitez, Turkey

            Comment


              #21
              Hi Norman, thanks for the code suggestion. The onsubmit method is still not being picked up by FB test events, however.

              The test onsubmit is working and the popup box shows the correct product code.

              This is the code from the opening form tag of layout, Customisable Product Layout:
              Code:
              <form method="post" accept-charset="iso-8859-1" class="imageOnLeftTextWrappedAround" onsubmit="fbq('track', 'AddToCart', {content_ids:['<actinic:variable name="ProductReference" encoding="perl" selectable="false" />'], content_type: 'product'}); return true;" action="<actinic:variable name="OnlineScriptURL" value="Shopping Cart Script URL" />" novalidate >
              Does it need to be placed elsewhere in that line or layout maybe?

              Comment


                #22
                Code looks OK. Test popup working shows you're putting it in the right place. Can't help further without seeing a live page.
                Norman - www.drillpine.biz
                Edinburgh, U K / Bitez, Turkey

                Comment

                Working...
                X