Announcement

Collapse
No announcement yet.

Commission Junction Tracking

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

    Commission Junction Tracking

    I'm working on getting the Commission Junction tracking added to a store and I'm having problems figuring out how to pull in information from the EmporiumPlus Coupon Redemption module into their script:
    Code:
    <!-- Commission Junction -->
    
    <script>
     var MasterTmsUdo = {
    
    
     'CJ' : {
     'CID': 'XXXXXXX',
     'TYPE': 'XXXXXX',
     'DISCOUNT' : '',
     'OID': '&mvte:item:order_id;',
     'CURRENCY' : 'USD',
     'COUPON' : '&mvte:order:coupons;',
     'FIRECJ' : 'TRUE',
    
    
     PRODUCTLIST : [
    
    
     { 
    <mvt:foreach iterator="item" array="order:items">
    'ITEM' : '&mvte:item:code;', 
    'AMT' : '&mvte:item:price;',
     'QTY' : '&mvte:item:quantity;' 
    'DCNT' : '' 
    
    
    <mvt:foreach iterator="option" array="item:options">
    </mvt:foreach>
    </mvt:foreach>
    }, 
     ] 
    } };
     </script>
    The DISCOUNT value specifies the total dollar amount to be deducted from the order subtotal.

    The DCNT value specifies the discount for the associated ITEM, and is distributed across the QTY for that ITEM.

    I know that the token I'm using to pull in the coupon code is not the correct token. I may not need the DCNT if I understand it correctly - it sounds like it's used for something like the Instant Coupon but the store doesn't use any.
    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: Commission Junction Tracking

    Emporium Plus has a single discount charge in the charges array. You can loop though that and check its type (I think he uses COUPON as the type) and set a variable with this value. This is what you can use for you DISCOUNT parameter.

    I don't think you're going to be able to calculate the item level discount, since that module does not break discounts out that why. However I don't think you need both types of discounts, it is typically one or the other.
    Brennan Heyde
    VP Product
    Miva, Inc.
    [email protected]
    https://www.miva.com

    Comment


      #3
      Re: Commission Junction Tracking

      Originally posted by Brennan View Post
      Emporium Plus has a single discount charge in the charges array. You can loop though that and check its type (I think he uses COUPON as the type) and set a variable with this value. This is what you can use for you DISCOUNT parameter.

      I don't think you're going to be able to calculate the item level discount, since that module does not break discounts out that why. However I don't think you need both types of discounts, it is typically one or the other.

      Could I use something like this?

      Code:
      <mvt:if expr="l.settings:order:charges:type EQ 'COUPON'">&mvt:global:order_charge:descrip;
      <mvt:if>
      The only problem I see with using &mvt:global:order_charge:descrip; is that it would display the results as Coupon: XXXXXX Is there a way to display just the coupon code?
      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


        #4
        Re: Commission Junction Tracking

        Try something like this:

        Code:
        <mvt:foreach iterator="charge" array="order:charges">
        	<mvt:if expr="l.settings:charge:type EQ 'COUPON'">
        		<mvt:assign name="g.coupon_total" value="g.coupon_total + l.settings:charge:amount" />
        	</mvt:if>
        </mvt:foreach>
        
        
        Total Coupon Discoints: &mvt:global:coupon_total;
        Brennan Heyde
        VP Product
        Miva, Inc.
        [email protected]
        https://www.miva.com

        Comment


          #5
          Re: Commission Junction Tracking

          Hmmm, it looks like my reply didn't post. This "works" but is there any way to display positive value (sans the minus sign)?

          Also I'm still having an issue getting the Coupon code to display. I'm using this to try and pull it in:

          Code:
          <mvt:foreach iterator="charge" array="order:charges"> <mvt:if expr="l.settings:charge:type EQ 'COUPON'">
           'COUPON' : '&mvt:order:charges:descrip;',
          </mvt:if>
          </mvt:foreach>
          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: Commission Junction Tracking

            I am having an issue with the yet another thing on this Commission Junction tracking (has no one else ever set this up before?)


            Code:
            <mvt:foreach iterator="item" array="order:items">{ 'ITEM' : '&mvte:item:code;', 
            'AMT' : '&mvte:item:price;',
            'QTY' : '&mvte:item:quantity;'}, 
            
            
            <mvt:foreach iterator="option" array="item:options">
            </mvt:foreach>
            </mvt:foreach>
             
             ]
            A comma is needed to separate each set, but the final set cannot have a comma after it. How do I keep that comma from showing up. It can't be there if it's only one item and can't be there after the final set.

            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


              #7
              Re: Commission Junction Tracking

              You'll need to count the items in the array and then conditionally display the comma like this

              This will return the number of items in the array:
              <mvt:assign name="g.array_count" value="miva_array_elements(l.settings:order:items) " />


              Then in your for each loop conditionally display the comma as long as it is not the last item:

              Code:
              <mvt:foreach iterator="item" array="order:items">
              
              
              ...
              
              
              	<mvt:if expr="l.pos1 LT g.array_count">
              		,
              	</mvt:if>
              </mvt:foreach>
              Brennan Heyde
              VP Product
              Miva, Inc.
              [email protected]
              https://www.miva.com

              Comment


                #8
                Re: Commission Junction Tracking

                With all of the Miva stores out there, no one else has attempted to configure tracking for Commission Junction?
                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: Commission Junction Tracking

                  Attached is a tutorial I found. Not sure if it exactly what you are looking for as it is from 2012.
                  Attached Files
                  Brennan Heyde
                  VP Product
                  Miva, Inc.
                  [email protected]
                  https://www.miva.com

                  Comment


                    #10
                    Re: Commission Junction Tracking

                    Thanks Brennan - the Conversion Tag is is almost there (it is slightly different from the PDF)

                    Code:
                    <!-- Commission Junction Conversion Tag  --><script>
                     var MasterTmsUdo = {
                    
                    
                     'CJ' : {
                     'CID': 'XXXXXXX',
                     'TYPE': 'XXXXXX',
                    <mvt:foreach iterator="charge" array="order:charges">
                            <mvt:if expr="l.settings:charge:type EQ 'COUPON'">
                                    <mvt:assign name="g.coupon_total" value="g.coupon_total + l.settings:charge:amount" />
                            </mvt:if>
                    </mvt:foreach>
                     'DISCOUNT' : '&mvt:global:coupon_total;',
                     'OID': '&mvt:order:id;',
                     'CURRENCY' : 'USD',
                    <mvt:foreach iterator="charge" array="order:charges">
                     <mvt:if expr="l.settings:charge:type EQ 'COUPON'">
                     'COUPON' : '&mvt:order:charges:descrip;',
                    </mvt:if>
                    </mvt:foreach>
                     'FIRECJ' : 'TRUE',
                    
                    
                     PRODUCTLIST : [
                    
                    
                     <mvt:assign name="g.array_count" value="miva_array_elements(l.settings:order:items)" />
                    <mvt:foreach iterator="item" array="order:items">
                    { 'ITEM' : '&mvte:item:code;', 
                    'AMT' : '&mvte:item:price;',
                    'QTY' : '&mvte:item:quantity;'}
                    
                    
                     <mvt:if expr="l.pos1 LT g.array_count">
                                    ,
                            </mvt:if>
                    
                    
                    <mvt:foreach iterator="option" array="item:options">
                    </mvt:foreach>
                    </mvt:foreach>
                     
                     ] 
                    } };
                     </script>
                    </mvt:if>
                    Everything in this snippet works (and passes good values per the Commission Junction Integration Engineer), except the items in red.

                    The
                    &mvt:global:coupon_total; has a minus sign as part of the value. The value must be a positive number to pass CJ requirements.

                    The &mvt:order:charges:descrip; doesn't pull in anything. Even if it did, it would be incorrect because just the COUPON Code is allowed to be passed through that value.

                    Here is what the engineer sees (from the view source):

                    Code:
                    <!-- Commission Junction Conversion Tag -->
                    <script>
                    var MasterTmsUdo = {
                    'CJ' : {
                    'CID': 'XXXXXXX',
                    'TYPE': 'XXXXXX',
                    'DISCOUNT' : '-3.29',
                    'OID': '34714',
                    'CURRENCY' : 'USD',
                    'COUPON' : '',
                    'FIRECJ' : 'TRUE',
                    PRODUCTLIST : [
                    { 'ITEM' : 'LOKAI', 'AMT' : '18',
                    'QTY' : '1'}
                    ,
                    { 'ITEM' : 'BCBOOK11-1', 'AMT' : '14.95',
                    'QTY' : '1'}
                    ] } };
                    </script>
                    Again, everything is good except these two items.

                    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


                      #11
                      Re: Commission Junction Tracking

                      You can fix the first issue by multiplying the coupon_total by -1. This will always force it to be positive:


                      Code:
                      <mvt:foreach iterator="charge" array="order:charges">
                              <mvt:if expr="l.settings:charge:type EQ 'COUPON'">
                                      <mvt:assign name="g.coupon_total" value="g.coupon_total + l.settings:charge:amount" />
                              </mvt:if>
                      </mvt:foreach>
                      <mvt:assign name="g.coupon_total" value="g.coupon_total * -1" />

                      For the second issue you'll need to do a glosub so only the coupon code is displayed (and you are referencing it incorrectly which is why it is blank)


                      Say for example the data in the charge description looks like this:


                      Coupon: 20OFF


                      You can output only the coupon by replacing the "Coupon:" with an empty string




                      <mvt:assign name="l.settings:charge:descrip" value="glosub(l.settings:charge:descrip,'Coupon:', '')" />
                      Then to output: &mvte:charge:descrip;
                      Brennan Heyde
                      VP Product
                      Miva, Inc.
                      [email protected]
                      https://www.miva.com

                      Comment


                        #12
                        Re: Commission Junction Tracking

                        Code:
                        <mvt:foreach iterator="charge" array="order:charges">
                                <mvt:if expr="l.settings:charge:type EQ 'COUPON'">
                                        <mvt:assign name="g.coupon_total" value="g.coupon_total + l.settings:charge:amount" />
                                </mvt:if>
                        </mvt:foreach>
                        <mvt:assign name="g.coupon_total" value="g.coupon_total * -1" />
                        'DISCOUNT' : '&mvt:global:coupon_total;',
                        This works great is there is a coupon value, but if there is no coupon value, it's now returning -0. I need either a 0 value or to leave the field empty. I was thinking it would been empty if there was no coupon.
                        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


                          #13
                          Re: Commission Junction Tracking

                          interesting.

                          Try initializing the g.coupon_total variable to 0 first:

                          Code:
                          <mvt:assign name="g.coupon_total" value="0" />
                          <mvt:foreach iterator="charge" array="order:charges">
                                  <mvt:if expr="l.settings:charge:type EQ 'COUPON'">
                                          <mvt:assign name="g.coupon_total" value="g.coupon_total + l.settings:charge:amount" />
                                  </mvt:if>
                          </mvt:foreach>
                          <mvt:assign name="g.coupon_total" value="g.coupon_total * -1" />
                          'DISCOUNT' : '&mvt:global:coupon_total;',
                          0 * -1 should be 0
                          Brennan Heyde
                          VP Product
                          Miva, Inc.
                          [email protected]
                          https://www.miva.com

                          Comment


                            #14
                            Re: Commission Junction Tracking

                            Interesting indeed - that didn't help - it's still coming up as -0 if a coupon is not used.

                            I'm still wondering why it's even putting anything in that field if there is no coupon since the if COUPON is being ignored? That seems to be were is breaking down at.

                            I tried this after I tried your suggestion:

                            Code:
                            <mvt:foreach iterator="charge" array="order:charges">        <mvt:if expr="l.settings:charge:type EQ 'COUPON'">
                                            <mvt:assign name="g.coupon_total" value="g.coupon_total + l.settings:charge:amount" />
                            				<mvt:else>
                            				<mvt:assign name="g.coupon_total" value="0" />
                                    </mvt:if>
                            </mvt:foreach>
                            <mvt:assign name="g.coupon_total" value="g.coupon_total * -1" />
                            'DISCOUNT' : '&mvt:global:coupon_total;',
                            It still produced the -0 but then it is still being multiplied by -1
                            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


                              #15
                              Re: Commission Junction Tracking

                              I'm testing a solution and will let you know if it works.
                              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