Announcement

Collapse
No announcement yet.

Facebook Pixel

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

    Facebook Pixel

    Hello everyone!

    I need help regarding with how to install a Facebook pixel for my client website.

    I tried to look for ways in Google and I cannot find any tutorial on this.

    Also, when the Facebook pixel is installed does it automatically track purchases?

    Need your help guys!

    Thanks

    #2
    Could also use some help in this arena - did you find anyone?

    Comment


      #3
      This might get you a start:

      Code:
      <!-- Facebook Pixel Code -->
      <script>
      !function(f,b,e,v,n,t,s){if(f.fbq)return;n=f.fbq=function(){n.callMethod?
      n.callMethod.apply(n,arguments):n.queue.push(arguments)};if(!f._fbq)f._fbq=n;
      n.push=n;n.loaded=!0;n.version='2.0';n.queue=[];t=b.createElement(e);t.async=!0;
      t.src=v;s=b.getElementsByTagName(e)[0];s.parentNode.insertBefore(t,s)}(window,
      document,'script','https://connect.facebook.net/en_US/fbevents.js');
      
      fbq("init", "PIXEL_ID_THING");
      fbq("track", "PageView");
      <mvt:if expr="'PROD' CIN g.Screen">
          fbq("track", "ViewContent", {
              content_type: 'product_group',
              content_ids: ["&mvte:product:code;"],
              content_name: "&mvte:product:name;",
              <mvt:if expr="NOT ISNULL g.Category_Code">
                  content_category: "&mvte:global:Category_Code;",
              </mvt:if>
              value: &mvte:product:price;,
              currency: 'USD'
          });
      </mvt:if>
      <mvt:if expr="g.Screen EQ 'BASK'">
      
          <mvt:comment>Concatenate product codes</mvt:comment>
          <mvt:foreach iterator="group" array="basket:groups">
              <mvt:if expr="pos1 EQ 1">
                  <mvt:assign name="g.group_codes" value="l.settings:group:code" />
              <mvt:else>
                  <mvt:assign name="g.group_codes" value="g.group_codes $ ', ' $ l.settings:group:code" />
              </mvt:if>
          </mvt:foreach>
      
          fbq("track", "AddToCart" {
              content_type: 'product_group',
              content_ids: ["&mvte:global:group_codes;"]
          }
      
          });
      </mvt:if>
      <mvt:if expr="g.Screen EQ 'OCST'">
          fbq("track", "InitiateCheckout");
      </mvt:if>
      <mvt:if expr="g.Screen EQ 'INVC'">
      
          <mvt:comment>Concatenate product codes</mvt:comment>
          <mvt:foreach iterator="item" array="order:items">
              <mvt:if expr="pos1 EQ 1">
                  <mvt:assign name="g.group_codes" value="l.settings:group:code" />
              <mvt:else>
                  <mvt:assign name="g.group_codes" value="g.group_codes $ ', ' $ l.settings:group:code" />
              </mvt:if>
          </mvt:foreach>
      
          fbq("track", "Purchase", {
              value: "&mvte:order:total;",
              currency: "USD",
              content_type: 'product_group',
              content_ids: ["&mvte:global:group_codes;"]
          });
      </mvt:if>
      </script>
      <noscript><img height="1" width="1" style="display:none" src="https://www.facebook.com/tr?id=PIXEL_ID_THING&ev=PageView&noscript=1"></noscript>
      <!-- End Facebook Pixel Code -->

      Comment


        #4
        Hi - We tried implementing your code in Google Tag Manager and we get this error " Error at line 11, character 2: Parse error. primary expression expected". Any way to fix this error? Thxs

        Comment


          #5
          UnfortunateIy, I don't think this code can be used directly in Tag Manager because it isn't 100% javascript. It iincludes SMT code that requires the Miva engine to parse it.

          Comment


            #6
            Leanne - the code you posted, do you just drop that in to Global Header and modify the needed parameters for the specific pixel?

            Comment


              #7
              The code goes into the head tag, not the global header, but otherwise, yes. As I recall, it was a bit finicky about where in the head tag it was placed -- it needed to be before certain other scripts in order to fire properly.

              Comment


                #8
                Would putting it as close to the top of the head tag work?

                Comment


                  #9
                  Yes, that should work.

                  Comment


                    #10
                    Hey all - so we have this code running and my fault for not noticing when, but product id's in the concatenate section are all coming into FB Pixel as just commas ",,,". Any ideas? Did something change with M10?

                    Comment


                      #11
                      In this section, I believe there is a typo. It should be item:code not group:code

                      Code:
                      
                      <mvt:if expr="g.Screen EQ 'INVC'">
                           <mvt:comment>Concatenate product codes</mvt:comment>
                           <mvt:foreach iterator="item" array="order:items">
                                <mvt:if expr="pos1 EQ 1">
                                     <mvt:assign name="g.group_codes" value="l.settings:item:code" />   
                                <mvt:else>
                                     <mvt:assign name="g.group_codes" value="g.group_codes $ ', ' $ l.settings:item:code" />
                                </mvt:if>
                           </mvt:foreach>   
                           fbq("track", "Purchase", { value: "&mvte:order:total;", currency: "USD", content_type: 'product_group', content_ids: ["&mvte:global:group_codes;"] });
                      </mvt:if>

                      Comment


                        #12
                        Does anyone have issues with their Pixel not tracking Conversions Data or ROAS in AdsManager now? Any idea how to fix this?

                        Facebook seems to be pushing us the route of implementing their new Conversions API to fix the issue but on our old pixel on our former Shopify site tracked this stuff no problem but since switching to a new pixel on our new Miva Site it hasn't been working despite our Pixel appearing to be set up correctly.

                        Comment

                        Working...
                        X