Announcement

Collapse
No announcement yet.

Trustpilot Integration

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

    Trustpilot Integration

    I have this code for the receipt page:

    Code:
    <!-- Trustpilot conversion script -->
    <script type="text/javascript">
    (function(c,o,n,v,e,r,t){c['TPConversionObject']=e;c[e]=c[e]||function(){c[e].buid='xxxxxxxxxxxxxxxxxxxxxxxx',(c[e].q=c[e].q||[]).push(arguments)};r=o.createElement(n),t=o.getElementsByTagName(n)[0];r.async=1;r.src=v;t.parentNode.insertBefore(r,t)})(window,document,'script','https://widget.trustpilot.com/conversion/conversion.js','tpConversion');
    
    tpConversion('amount', '<Actinic:Variable Name="Total"/>'); // total cost of the order, eg. '13.00'
    tpConversion('currency', 'GBP'); // your shop's currency, e.g. USD
    tpConversion('basket_size', '[BASKET_SIZE]'); // total number of items purchased
    </script>
    <!-- End Trustpilot conversion script -->
    Can I use
    Code:
    document.write(getCartItem(3));
    for basket size? Wil it work in the receipt page and how might it be included in the above script?

    Thank you
    Jonathan Chappell
    Website Designer
    SellerDeck Website Designer
    Actinic to SellerDeck upgrades
    Graphicz Limited - www.graphicz.co.uk

    #2
    Originally posted by graphicz View Post

    Can I use
    Code:
    document.write(getCartItem(3));
    for basket size? Wil it work in the receipt page and how might it be included in the above script?

    Thank you
    I'm not sure that will work as I think by that point the cart cookie has been cleared.

    There is a list of available variables by location in Help > Variable Reference Guide which doesn't show anything useful for the number of items in the cart.

    There might be some new variables available from when the new Google analytics code was introduced but I haven't seen any documentation on them. Sorry.

    If no one else has a solution then worst case you can always create a duplicate cart cookie of your own and use that.

    Mike
    -----------------------------------------

    First Tackle - Fly Fishing and Game Angling

    -----------------------------------------

    Comment


      #3
      Thank you Mike

      I thought as much as using the code I mentioned generated a big fat 0 in preview!
      Jonathan Chappell
      Website Designer
      SellerDeck Website Designer
      Actinic to SellerDeck upgrades
      Graphicz Limited - www.graphicz.co.uk

      Comment


        #4
        I know it's a bit painful, could you add an ID/class to the containing TR tag of an item in cart and count those with jquery and pass results back to the TP script?


        EDIT: Stackoverflow link - https://stackoverflow.com/questions/...ows-in-a-table
        Matt. M - SMR Enterprises Ltd.

        Comment


          #5
          That's an interesting way to do it. I hadn't thought of anything like that but it should work.
          -----------------------------------------

          First Tackle - Fly Fishing and Game Angling

          -----------------------------------------

          Comment


            #6
            That's how I do it. I've done Trustpilot and Google Trusted Stores integrations before and adding class-names to the assorted bit of Cart data help you get at them. Note that you have to deal with the SD generated text being formatted.

            You don't need document.writes. E.g (untested).
            Code:
            <!-- Trustpilot conversion script -->
            <script type="text/javascript">
            // SellerDeck tweaks start
            // SellerDeck amount may have £ sign and thousand commas
            function getcartamount(){
            	return ('<Actinic:Variable Name="Total"/>').replace(/[^0-9\.]/g, '');
            }
            
            // we've added a cartqtyfield class-name to the Qty field in the checkout
            function getcarttotalitems(){
            	var basket_size = 0;
            	$( ".cartqtyfield" ).each(function(){
            		var itemcount = $(this).text();
            		if ( ! isNaN(itemcount) )
            			{
            			basket_size += itemcount - 0;
            			}
            		});
            	return basket_size;
            }
            // SellerDeck tweaks end
            
            // TP code continues
            (function(c,o,n,v,e,r,t){c['TPConversionObject']=e;c[e]=c[e]||function(){c[e].buid='xxxxxxxxxxxxxxxxxxxxxxxx',(c[e].q=c[e].q||[]).push(arguments)};r=o.createElement(n),t=o.getElementsByTagName(n)[0];r.async=1;r.src=v;t.parentNode.insertBefore(r,t)})(window,document,'script','https://widget.trustpilot.com/conversion/conversion.js','tpConversion');
            
            tpConversion('amount', getcartamount()); // total cost of the order, eg. '13.00'
            tpConversion('currency', 'GBP'); // your shop's currency, e.g. USD
            tpConversion('basket_size', getcarttotalitems()); // total number of items purchased
            </script>
            <!-- End Trustpilot conversion script -->
            Norman - www.drillpine.biz
            Edinburgh, U K / Bitez, Turkey

            Comment


              #7
              Norman,

              I'm always wary of raising issues with people who know things far better than me, but shouldn't there be a '{' after

              function getcarttotalitems()
              ?

              It's odd as I assume you've just copied and pasted this which is why I'm so hesitant in asking.

              Mike
              -----------------------------------------

              First Tackle - Fly Fishing and Game Angling

              -----------------------------------------

              Comment


                #8
                Originally posted by Mike Hughes View Post
                Norman,

                I'm always wary of raising issues with people who know things far better than me, but shouldn't there be a '{' after

                ?

                It's odd as I assume you've just copied and pasted this which is why I'm so hesitant in asking.

                Mike
                Yes there should - Norman's got the closing curly brace at the end waiting for it :P
                Matt. M - SMR Enterprises Ltd.

                Comment


                  #9
                  Fixed the missing {.

                  Code was just written for the OP and I did say "untested" ;-)
                  Norman - www.drillpine.biz
                  Edinburgh, U K / Bitez, Turkey

                  Comment


                    #10
                    Thank you so much Norman

                    Just to confirm the class 'cartqtyfield' is added to the span or div containing the quantity, eg:
                    Code:
                    <span class="floatRight cartqtyfield"><Actinic:Variable Name="Quantity"/></span>
                    or
                    Code:
                    	<div class="text-right small-3 large-2 columns cartqtyfield">
                    	  <Actinic:Variable Name="Quantity"/>
                    	</div>
                    Depending on the layout design?
                    Jonathan Chappell
                    Website Designer
                    SellerDeck Website Designer
                    Actinic to SellerDeck upgrades
                    Graphicz Limited - www.graphicz.co.uk

                    Comment


                      #11
                      I am getting "basket_size is undefined" ?
                      Jonathan Chappell
                      Website Designer
                      SellerDeck Website Designer
                      Actinic to SellerDeck upgrades
                      Graphicz Limited - www.graphicz.co.uk

                      Comment


                        #12
                        Have you got your { as discussed above?
                        -----------------------------------------

                        First Tackle - Fly Fishing and Game Angling

                        -----------------------------------------

                        Comment


                          #13
                          Thought Norman said he had fixed it?
                          The code above has 6 { and 6 }
                          Jonathan Chappell
                          Website Designer
                          SellerDeck Website Designer
                          Actinic to SellerDeck upgrades
                          Graphicz Limited - www.graphicz.co.uk

                          Comment


                            #14
                            The basket_size variable - is this looking for number of unique item rows (what about components?), number of quantity per row, or number of rows x quantity?

                            If you want to return quantities, tag those, if you want to return item rows, tag the containing tr, if you want to do the maths and return total amount of items, tag both and sum them.
                            Matt. M - SMR Enterprises Ltd.

                            Comment


                              #15
                              Fixed a typo. Try now.
                              Norman - www.drillpine.biz
                              Edinburgh, U K / Bitez, Turkey

                              Comment

                              Working...
                              X