Announcement

Collapse
No announcement yet.

Coding a Conversion Tracking Pixel

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

    Coding a Conversion Tracking Pixel

    Store owner needs to add a Conversion Tracking Pixel to the INVC screen for a service they have signed up for. Not sure if the company has ever worked with Miva Merchant before so I'm trying to figure this out as I go along. Here's what I'm trying to figure out:

    <subtotal> is the subtotal of the order, excluding taxes and shipping.
    <order_id> is your site-specific order id; this can be up to 128 characters long.
    <product_skus> is the list of product skus in the order. Multiple skus should be separated by a comma “,”. Please note that skus containing "/" need to be URL-encoded in order to be supported.
    <order_id> seems easy enough - &mvt:order:id;

    <subtotal> I'm thinking this might be - &mvt:item:subtotal; (it can't include the $)

    <product_skus> - well this one, I'm guess is going to need to have some sort of foreach iterator but how is that going to work for a URL?

    Code:
    <img width="1" height="1" src="https://www.trackingcompany.com/conversion/beacon.gif?adv=<retailer_host_name>&amt=&mvt:item:subtotal;&oid=&mvt:order:id;&skus=<product_skus>&cur=usd">
    Thanks,
    Leslie
    Leslie Kirk
    Miva Certified Developer
    Miva Merchant Specialist since 1997
    Previously of Webs Your Way
    (aka Leslie Nord leslienord)

    Email me: [email protected]
    www.lesliekirk.com

    Follow me: Twitter | Facebook | FourSquare | Pinterest | Flickr

    #2
    Re: Coding a Conversion Tracking Pixel

    subtotal should be the bare value, if not, just use <mvt:assign name="l.thisOrderTotal" value="glosub(l.settings:order:subtotal, '$', '')" />

    For products, just use:

    <mvt:if expr="g.productList">
    <mvt:assign name="g.productList" value="g.productList $ l.settings:item:code $ ','" />
    <mvt:else>
    <mvt:assign name="g.productList" value="g.productList $ l.settings:item:code" />
    </mvt:if>

    then use g.productList in the pixel.
    Bruce Golub
    Phosphor Media - "Your Success is our Business"

    Improve Your Customer Service | Get MORE Customers | Edit CSS/Javascript/HTML Easily | Make Your Site Faster | Get Indexed by Google | Free Modules | Follow Us on Facebook
    phosphormedia.com

    Comment


      #3
      Re: Coding a Conversion Tracking Pixel

      There is no variable by default which includes the order's subtitle before tax and shipping. You can create both of the missing variables inside the order contents element like so (new code added to the CSSUI default highlighted in red):

      Code:
      <mvt:if expr="l.settings:basket:empty">
      Your shopping basket is currently empty.
      <p><mvt:item name="cssui_links" param="storefront">Home</mvt:item></p>
      <mvt:exit />
      </mvt:if>
      <table>
          <tr class="basket-heading">
              <td class="item-name">Item</td>
              <td class="item-quantity">Qty.</td>
              <td class="item-price">Item Price</td>
              <td class="item-total">Total Price</td>
          </tr>
      <mvt:assign name="g.orderSubtotal" value="0" />
          <mvt:foreach iterator="item" array="basket:items">
      <mvt:assign name="g.orderSubtotal" value="g.orderSubtotal + l.settings:item:price" />
          <tr>
              <td class="item-name">
                  <div class="special-offer"><mvt:if expr="l.settings:item:upsold">(Special Offer)</mvt:if></div>
                  <div class="item-name">&mvt:item:name; - 
                  <span class="item-code">
                      &mvt:item:code;
                  </span>
                  </div>
              </td>
              <td class="item-quantity">
                  &mvt:item:quantity;
              </td>
              <td class="item-price">&mvt:item:formatted_price;</td>
              <td class="item-total">&mvt:item:formatted_subtotal;</td>
          </tr>
          <mvt:foreach iterator="option" array="item:options">
      <mvt:assign name="g.orderSubtotal" value="g.orderSubtotal + l.settings:option:price" />
      <mvt:if expr="pos1 EQ 0">
      <mvt:assign name="g.productSKUs" value="g.productSKUs $ l.settings:item:code" />
      <mvt:else>
      <mvt:assign name="g.productSKUs" value="g.productSKUs $ l.settings:item:code $ ','" />
      </mvt:if>
          <tr class="item-options">
              <td class="item-name">
                  <mvt:if expr="l.settings:option:option_id">
                  &mvt:option:attr_code;: &mvt:option:opt_code;
                  <mvt:elseif expr="NOT ISNULL l.settings:option:data">
                  &mvt:option:attr_code;: &mvt:option:data;
                  <mvt:elseif expr="NOT ISNULL l.settings:option:data_long">
                  &mvt:option:attr_code;: &mvt:option:data_long;
                  <mvt:else>
                  &mvt:option:attr_code;
                  </mvt:if>
              </td>
              <td class="item-quantity">&nbsp;</td>
              <td class="item-price">
                  <mvt:if expr="l.settings:option:price">
                  &mvt:option:formatted_price;
                  <mvt:else>
                  &nbsp;
                  </mvt:if>
              </td>
              <td class="item-total">
                  <mvt:if expr="l.settings:option:price">
                  &mvt:option:formatted_subtotal;
                  <mvt:else>
                  &nbsp;
                  </mvt:if>
              </td>
          </tr>
          </mvt:foreach>
          </mvt:foreach>
          <mvt:foreach iterator="charge" array="basket:charges">
          <tr class="basket-charges">
              <td colspan="2">&nbsp;</td>
              <td class="charge-description">&mvt:charge:descrip;:</td>
              <td class="formatted-charge">&mvt:charge:formatted_disp_amt;</td>
          </tr>
          </mvt:foreach>
          <tr id="basket-totals">
              <td colspan="2">&nbsp;</td>
              <td class="total-prompt">Total:</td>
              <td class="formatted-total">&mvt:basket:formatted_total;</td>
          </tr>
      </table>
      <div class="clear"></div>
      You can then use &mvt:global:orderSubtotal; for the subtotal minus charges, and &mvt:global:productSKUs; for the delimited list of product codes.
      Kyle Newbrough
      Technical Support / Web Developer
      Miva Merchant

      Comment


        #4
        Re: Coding a Conversion Tracking Pixel

        Kyle,

        Color me confused. The INVC screen (I'm working with) has an Order Contents but I'm thinking I can use this code in that field?

        Leslie
        Leslie Kirk
        Miva Certified Developer
        Miva Merchant Specialist since 1997
        Previously of Webs Your Way
        (aka Leslie Nord leslienord)

        Email me: [email protected]
        www.lesliekirk.com

        Follow me: Twitter | Facebook | FourSquare | Pinterest | Flickr

        Comment


          #5
          Re: Coding a Conversion Tracking Pixel

          And what is the delimited that will be used? Just found out
          Multiple skus should be separated by a comma “,”.
          Leslie
          Leslie Kirk
          Miva Certified Developer
          Miva Merchant Specialist since 1997
          Previously of Webs Your Way
          (aka Leslie Nord leslienord)

          Email me: [email protected]
          www.lesliekirk.com

          Follow me: Twitter | Facebook | FourSquare | Pinterest | Flickr

          Comment


            #6
            Re: Coding a Conversion Tracking Pixel

            Okay - just did a test with the code from Kyle (and I see that the delimiter was/is a comma). It pulled the subtotal nicely, but only pulled the first product

            Code:
            https://www.trackinglink.com/conversion/beacon.gif?adv=retailer_host_name&amt=43&oid=21861&skus=LOKAI,&cur=usd
            Leslie Kirk
            Miva Certified Developer
            Miva Merchant Specialist since 1997
            Previously of Webs Your Way
            (aka Leslie Nord leslienord)

            Email me: [email protected]
            www.lesliekirk.com

            Follow me: Twitter | Facebook | FourSquare | Pinterest | Flickr

            Comment


              #7
              Re: Coding a Conversion Tracking Pixel

              Hi Leslie,

              I'm not sure I'm totally clear on your question but I'll try to explain and rephrase.

              The code added in red would go into the Order Contents items/options foreach loops. It creates a variable (g.orderSubtotal) which adds all item and attribute prices together to give you a subtotal value before taxes, shipping, or other charges are added to the total.

              The g.productSKUs variable, similarly, creates a comma-delimited list of product codes.

              I also made a mistake in my example code for the SKUs so use this instead:

              Code:
              <table><tr class="basket-heading">
              <td class="item-name">Item</td>
              <td class="item-quantity">Qty.</td>
              <td class="item-price">Item Price</td>
              <td class="item-total">Total Price</td>
              </tr>
              <mvt:assign name="g.orderSubtotal" value="0" />
              <mvt:foreach iterator="item" array="order:items">
              <mvt:assign name="g.orderSubtotal" value="g.orderSubtotal + l.settings:item:price" />
              <mvt:assign name="g.productSKUs" value="g.productSKUs $ l.settings:item:code $ ','" />
              <tr>
              <td class="item-name">
              <div class="special-offer"><mvt:if expr="l.settings:item:upsold">(Special Offer)</mvt:if></div>
              <div class="item-name">
              &mvt:item:name; - <span class="item-code">
              &mvt:item:code;
              </span>
              </div>
              </td>
              <td class="item-quantity">
              &mvt:item:quantity;
              </td>
              <td class="item-price">
              &mvt:item:formatted_price;
              </td>
              <td class="item-total">
              &mvt:item:formatted_subtotal;
              </td>
              </tr>
              <mvt:foreach iterator="option" array="item:options">
              <mvt:assign name="g.orderSubtotal" value="g.orderSubtotal + l.settings:option:price" />
              <tr class="item-options">
              <td class="item-name">
              <mvt:if expr="l.settings:option:option_id">
              &mvt:option:attr_code;: &mvt:option:opt_code;
              <mvt:elseif expr="NOT ISNULL l.settings:option:data">
              &mvt:option:attr_code;: &mvt:option:data;
              <mvt:elseif expr="NOT ISNULL l.settings:option:data_long">
              &mvt:option:attr_code;: &mvt:option:data_long;
              <mvt:else>
              &mvt:option:attr_code;
              </mvt:if>
              </td>
              <td class="item-quantity">&nbsp;</td>
              <td class="item-price">
              <mvt:if expr="l.settings:option:price">
              &mvt:option:formatted_price;
              <mvt:else>
              &nbsp;
              </mvt:if>
              </td>
              <td class="item-total">
              <mvt:if expr="l.settings:option:price">
              &mvt:option:formatted_subtotal;
              <mvt:else>
              &nbsp;
              </mvt:if>
              </td>
              </tr>
              </mvt:foreach>
              </mvt:foreach>
              <mvt:foreach iterator="charge" array="order:charges">
              <tr class="basket-charges">
              <td colspan="2">&nbsp;</td>
              <td class="charge-description">
              &mvt:charge:descrip;:
              </td>
              <td class="formatted-charge">
              &mvt:charge:formatted_disp_amt;
              </td>
              </tr>
              </mvt:foreach>
              <tr	id="basket-totals">
              <td colspan="2">&nbsp;</td>
              <td class="total-prompt">
              Total:
              </td>
              <td class="formatted-total">
              &mvt:order:formatted_total;
              </td>
              </tr>
              </table>
              <div class="clear"></div>
              subtotal: &mvt:global:orderSubtotal;
              skus: &mvt:global:productSKUs;

              If the SKUs list can't end in a trailing comma then things get a little more complicated. Let me know whether that's a problem for the pixel.
              Kyle Newbrough
              Technical Support / Web Developer
              Miva Merchant

              Comment


                #8
                Re: Coding a Conversion Tracking Pixel

                Ohhh, even more interesting, if just one item is ordered the skus is empty
                Code:
                https://www.trackinglink.com/conversion/beacon.gif?adv=retailer_host_name&amt=30&oid=21862&skus=&cur=usd
                Leslie Kirk
                Miva Certified Developer
                Miva Merchant Specialist since 1997
                Previously of Webs Your Way
                (aka Leslie Nord leslienord)

                Email me: [email protected]
                www.lesliekirk.com

                Follow me: Twitter | Facebook | FourSquare | Pinterest | Flickr

                Comment


                  #9
                  Re: Coding a Conversion Tracking Pixel

                  Interesting. I guess mvt:assign is less flexible than I hoped and fails if the first variable being concatenated is null.

                  Try this in place of the red code in my last post:

                  Code:
                  <mvt:if expr="g.productSKUs">
                    <mvt:assign name="g.productSKUs" value="g.productSKUs $ l.settings:item:code $ ','" />
                  <mvt:else>
                    <mvt:assign name="g.productSKUs" value="l.settings:item:code $ ','" />
                  </mvt:if>
                  
                  Kyle Newbrough
                  Technical Support / Web Developer
                  Miva Merchant

                  Comment


                    #10
                    Re: Coding a Conversion Tracking Pixel

                    Before I make the second change here is what I have:

                    Code:
                    <hr><strong>YOUR ORDER </strong>
                    <hr>
                    <div style="float:left;">
                    <table border="0" cellpadding="5" cellspacing="0">
                    <mvt:assign name="g.orderSubtotal" value="0" />
                      <mvt:foreach iterator="item" array="order:items">
                      <mvt:assign name="g.orderSubtotal" value="g.orderSubtotal + l.settings:item:price" />
                        <tr>
                          <td rowspan="2" align="left" valign="middle">
                            <mvt:item name="toolkit" param="prodthumb|imgurl|l.all_settings:item:code" />
                              <mvt:if expr="g.imgurl"><a href="&mvt:global:sessionurl;Screen=PROD&Store_Code=&mvta:global:Store_Code;&Product_Code=&mvta:item:code;"><img src="&mvte:global:imgurl;" border="0" height="200"></a>
                              </mvt:if> 
                          </td>
                          <td align="left" valign="top">
                            
                            <span class="basket-txt">&mvt:item:name;</span><br>
                            <mvt:if expr="l.settings:item:upsold"> <span class="basket-txt">(Special Offer)</span><br> </mvt:if>
                            <mvt:foreach iterator="option" array="item:options">
                            <mvt:assign name="g.orderSubtotal" value="g.orderSubtotal + l.settings:option:price" />
                    <mvt:if expr="pos1 EQ 0">
                    <mvt:assign name="g.productSKUs" value="g.productSKUs $ l.settings:item:code" />
                    <mvt:else>
                    <mvt:assign name="g.productSKUs" value="g.productSKUs $ l.settings:item:code $ ','" />
                    </mvt:if>
                              <mvt:if expr="'c' CIN l.settings:option:attr_code">
                                &mvt:option:attr_code;: &mvt:option:opt_code;<br>
                              </mvt:if>
                              
                              <mvt:if expr="'S' CIN l.settings:option:attr_code">
                                &mvt:option:attr_code;: &mvt:option:opt_code;<br>
                                <script>
                    				 document.getElementById('size').style.display ='block';
                    				 </script>
                                
                              </mvt:if>
                             </mvt:foreach> 
                          </td>
                          <td align="left" valign="top">
                          <mvt:if expr="l.settings:option:price">
                    &mvt:option:formatted_price;
                    <mvt:else>
                     &mvt:item:formatted_price;
                    </mvt:if></td>
                        </tr>
                        <tr>
                          <td colspan="2" align="left" valign="top">&nbsp;</td>
                        </tr>
                      
                      </mvt:foreach>
                    </table>
                    </div>
                    <div style="float:right;">
                    <table border="0" cellpadding="5" cellspacing="0">
                    <tr>
                      <td>SUBTOTAL</td>
                    <td>
                     <mvt:if expr="l.settings:option:price">
                    &mvt:option:formatted_subtotal;
                    <mvt:else>
                    &mvt:item:formatted_subtotal;
                    </mvt:if>
                    </td>
                    </tr>
                    <mvt:foreach iterator="charge" array="order:charges">
                    <tr>
                      <td>&mvt:charge:descrip;</td>
                      <td>&mvt:charge:formatted_disp_amt;</td>
                    </tr>
                    
                    
                    </mvt:foreach>
                    <tr>
                      <td><strong>ORDER TOTAL</strong></td>
                      <td><strong>&mvt:order:formatted_total;</strong></td>
                    </tr>
                    </table>
                    
                    
                    </div>
                    <div style="clear:both;"></div>
                    and you suggest changing it to

                    Code:
                    <hr><strong>YOUR ORDER </strong>
                    <hr>
                    <div style="float:left;">
                    <table border="0" cellpadding="5" cellspacing="0">
                    <mvt:assign name="g.orderSubtotal" value="0" />
                      <mvt:foreach iterator="item" array="order:items">
                      <mvt:assign name="g.orderSubtotal" value="g.orderSubtotal + l.settings:item:price" />
                      
                      <mvt:if expr="g.productSKUs">
                      <mvt:assign name="g.productSKUs" value="g.productSKUs $ l.settings:item:code $ ','" />
                    <mvt:else>
                      <mvt:assign name="g.productSKUs" value="l.settings:item:code $ ','" />
                    </mvt:if>
                      
                        <tr>
                          <td rowspan="2" align="left" valign="middle">
                            <mvt:item name="toolkit" param="prodthumb|imgurl|l.all_settings:item:code" />
                              <mvt:if expr="g.imgurl"><a href="&mvt:global:sessionurl;Screen=PROD&Store_Code=&mvta:global:Store_Code;&Product_Code=&mvta:item:code;"><img src="&mvte:global:imgurl;" border="0" height="200"></a>
                              </mvt:if> 
                          </td>
                          <td align="left" valign="top">
                            
                            <span class="basket-txt">&mvt:item:name;</span><br>
                            <mvt:if expr="l.settings:item:upsold"> <span class="basket-txt">(Special Offer)</span><br> </mvt:if>
                            <mvt:foreach iterator="option" array="item:options">
                            <mvt:assign name="g.orderSubtotal" value="g.orderSubtotal + l.settings:option:price" />
                    <mvt:if expr="pos1 EQ 0">
                    <mvt:assign name="g.productSKUs" value="g.productSKUs $ l.settings:item:code" />
                    <mvt:else>
                    <mvt:assign name="g.productSKUs" value="g.productSKUs $ l.settings:item:code $ ','" />
                    </mvt:if>
                              <mvt:if expr="'c' CIN l.settings:option:attr_code">
                                &mvt:option:attr_code;: &mvt:option:opt_code;<br>
                              </mvt:if>
                              
                              <mvt:if expr="'S' CIN l.settings:option:attr_code">
                                &mvt:option:attr_code;: &mvt:option:opt_code;<br>
                                <script>
                    				 document.getElementById('size').style.display ='block';
                    				 </script>
                                
                              </mvt:if>
                             </mvt:foreach> 
                          </td>
                          <td align="left" valign="top">
                          <mvt:if expr="l.settings:option:price">
                    &mvt:option:formatted_price;
                    <mvt:else>
                     &mvt:item:formatted_price;
                    </mvt:if></td>
                        </tr>
                        <tr>
                          <td colspan="2" align="left" valign="top">&nbsp;</td>
                        </tr>
                      
                      </mvt:foreach>
                    </table>
                    </div>
                    <div style="float:right;">
                    <table border="0" cellpadding="5" cellspacing="0">
                    <tr>
                      <td>SUBTOTAL</td>
                    <td>
                     <mvt:if expr="l.settings:option:price">
                    &mvt:option:formatted_subtotal;
                    <mvt:else>
                    &mvt:item:formatted_subtotal;
                    </mvt:if>
                    </td>
                    </tr>
                    <mvt:foreach iterator="charge" array="order:charges">
                    <tr>
                      <td>&mvt:charge:descrip;</td>
                      <td>&mvt:charge:formatted_disp_amt;</td>
                    </tr>
                    
                    
                    </mvt:foreach>
                    <tr>
                      <td><strong>ORDER TOTAL</strong></td>
                      <td><strong>&mvt:order:formatted_total;</strong></td>
                    </tr>
                    </table>
                    
                    
                    </div>
                    <div style="clear:both;"></div>
                    If I add the new change (in purple) will it conflict with the existing (in red)?
                    Leslie Kirk
                    Miva Certified Developer
                    Miva Merchant Specialist since 1997
                    Previously of Webs Your Way
                    (aka Leslie Nord leslienord)

                    Email me: [email protected]
                    www.lesliekirk.com

                    Follow me: Twitter | Facebook | FourSquare | Pinterest | Flickr

                    Comment


                      #11
                      Re: Coding a Conversion Tracking Pixel

                      Leslie,

                      Just remove the red from that example and leave the purple where it is, and you should be good to go. I have no idea what I was thinking when I gave you that first example code, there were several mistakes. Sorry for the confusion!
                      Kyle Newbrough
                      Technical Support / Web Developer
                      Miva Merchant

                      Comment


                        #12
                        Re: Coding a Conversion Tracking Pixel

                        Hi Kyle,

                        No worries!!! It looks to me like the code (sans the red) is now working as "I" expect it to. Now I just need to hear back from the tracking company.

                        Many, many thanks!
                        Leslie
                        Leslie Kirk
                        Miva Certified Developer
                        Miva Merchant Specialist since 1997
                        Previously of Webs Your Way
                        (aka Leslie Nord leslienord)

                        Email me: [email protected]
                        www.lesliekirk.com

                        Follow me: Twitter | Facebook | FourSquare | Pinterest | Flickr

                        Comment

                        Working...
                        X