Need help with custom order field for relaying http-referer

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • kwgarrett
    Mivite

    • Oct 2008
    • 135

    #1

    Need help with custom order field for relaying http-referer

    I'm trying to better track the sources of my sales, in particular for justification of spending money on Adwords and Amazon Product Ads. I'd like to capture the http-referer and/or a URL Query String and pass that through the shopper's session to be stuffed into an Additional Checkout Data field and then downloaded into our order processing software, Shipworks.


    I've got some of it figured out. I have successfully captured the http-referer in a custom order field, told Additional Checkout Data about it, and it downloads into Shipworks. But what I haven't figured out is how to prevent the initial external referrer from being overwritten.




    I put the following into the Head Tag Content so it will be available everywhere:


    Code:
    <mvt:item name="customfields" param="Read_Basket( 'httprefererfield', l.settings:custom_basket_httprefererfield )" />
    <mvt:if expr="ISNULL l.settings:custom_basket_httprefererfield">
        <mvt:item name="customfields" param="Write_Basket('httprefererfield', s.http_referer)" />
    </mvt:if>


    I am testing this with the following code at the bottom of pages:


    Code:
    <mvt:item name="customfields" param="Read_Basket( 'httprefererfield', l.settings:custom_basket_httprefererfield )" />
    <span style="color:white">&mvte:custom_basket_httprefererfield;</span>
    This shows the initial pickup of the external referrer, but upon page navigation, it reveals that httprefererfield is overwritten.


    The problem is in NOT overwriting the initial capture of the external referrer. That's the purpose of the initial Read_Basket and the conditional. However it doesn't seems to work. The Write_Basket occurs anyway and so I get intra-site referrers, which is useless. What i need to do is find a way to only write the initial referrer once and not overwrite the custom order field for a customer's session.


    I've tried a variety of items to test but can't find any condition that prevents subsequent Write_Basket from occurring (or prevents all occurrences including the initial). I'm not smart enough to figure this out and I've exhausted trial and error. Hoping someone can help.


    Thanks


    Kevin Garrett
  • dcarver
    Director of Software Dev.




    • May 2013
    • 400

    #2
    Re: Need help with custom order field for relaying http-referer

    Hi Kevin,

    Which version of the software are you running? I copy and pasted your exact code into my global header/footer and it worked accordingly.

    In addition, I would like to clarify exactly what you are doing. I added the code and then clicked my 'View Store' button. I saw my custom field value at the bottom of the page listed as
    Code:
    [URL]http://..../mm5/admin.mvc?Random=Stuff[/URL]
    . When I clicked any other pages, the custom field always printed out my admin.mvc URL and never changed. This is what you are looking for correct?

    Thanks
    Last edited by sartaingerous; 07-28-17, 02:11 PM.
    David Carver
    Miva, Inc. | Software Developer

    Comment

    • kwgarrett
      Mivite

      • Oct 2008
      • 135

      #3
      Re: Need help with custom order field for relaying http-referer

      Miva Merchant 5.5
      Production Release 8 Update 12
      Miva Merchant Engine v5.19
      Database API: mysq

      I'm not sure what to say except that there were times when some test in the conditional prevented it from running the Write_Basket command, so that whatever referrer was there already was always presented (and the first time I saw it I thought I had succeeded until I tested further). It might be that the code I posted was one of those iterations.

      I think the only way to properly test this is to access the site from a different domain, which is what I've been doing. That way I see a proper external referring site in the debugging display at the bottom of the page. But going to another page overwrites it with the internal referring page.

      I've been looking to see if there's a module that already does what I want. It looks like Copernicus' Search Engine Tracker did this, but is no longer offered from what I can tell.

      Kevin

      Comment

      • kwgarrett
        Mivite

        • Oct 2008
        • 135

        #4
        Re: Need help with custom order field for relaying http-referer

        Well, now I'm confused. I just tested my site and it seems to work. HOWEVER, there is evidence that it is not working. Looking through orders placed since I last changed the code, none of the Custom Order fields and Additional Checkout Data Pro fields have the external referrer recorded. The data is all internal urls. Those URLs appear to be the landing pages.

        Kevin Garrett

        Comment

        • kwgarrett
          Mivite

          • Oct 2008
          • 135

          #5
          Re: Need help with custom order field for relaying http-referer

          Yeah, doesn't work. If you use a browser extension like "Forget Me" then you'll see it that my code fails.



          So that means I still need help!

          Thanks
          Kevin Garrett

          Comment

          • dcarver
            Director of Software Dev.




            • May 2013
            • 400

            #6
            Re: Need help with custom order field for relaying http-referer

            Hi Kevin,

            I've setup a store that meets your specifications and unfortunately I cannot reproduce the error. The code you pasted works exactly as it should.

            Do you have any other 3rd party modules installed? Do you have access to view your database? Have you changed your cookie settings?

            The only issue I can imagine, is if for some reason every page load something weird is going on with your cookies and a new basket is being created, which would mean that the new basket does not have the 'httpreferer' field set and is writing the value again.

            If you have access to your database, you should view your sNN_BasketInfo table. You should refresh that table after each page hit and see if the value changes for your basket id OR if you have a new basket id with a new record inserted.


            In addition, try changing your footer code to display the basket id to see if it changes
            Code:
            <span style="color:white">&mvte:custom_basket_httprefererfield; -- &mvte:global:basket:basket_id;</span>

            Let me know if this helps you at all.

            Thanks
            David Carver
            Miva, Inc. | Software Developer

            Comment

            • kwgarrett
              Mivite

              • Oct 2008
              • 135

              #7
              Re: Need help with custom order field for relaying http-referer

              I'll give that a try. Thanks for the debugging tips. Regarding the error, the proof of the pudding is in the data that is captured with the orders. I am not getting external referrers pass through.




              I have done some more testing. First off, it is vital to clear cookies and history each time for testing. Using "Forget Me," I have the following options set:

              Close page after data deletion
              Delete Cookies
              Delete History
              Delete also all domain's history, not just current URL
              Clear local storage

              Despite that, I get inconsistent results. Sometimes it seems fixed, sometimes (most times) the referrer is overwritten.

              You can try it yourself. The debugging info is at the bottom of the page in white (select all to view). The referrer does not appear on pages without the customfields item turned on.

              The store url is : http://www.podmerchant.com/

              Try also from a product page such as: http://www.podmerchant.com/espresso-...esso-pods.html

              Oh, and yes, I have a boat-load of 3rd party modules.

              Thanks for your continued interest in my problem.

              Kevin
              Last edited by kwgarrett; 12-12-13, 10:06 AM.

              Comment

              • dcarver
                Director of Software Dev.




                • May 2013
                • 400

                #8
                Re: Need help with custom order field for relaying http-referer

                Hi Kevin,

                I checked out your site. The issue involves the way you have your cookie settings setup. I viewed the source of the page, and noticed I was getting a new basket id every time I loaded the page. This should not be happening. Once I load your site, I should have a cookie saved to my browser and use that cookie throughout the checkout process. Your site did not set a cookie until I added a product to my basket. At that point, the referrer URL stopped being overwritten. You should be able to test this by clearing all cookies on your site, navigating around your site and noticing the referrer being overwritten every time, as well as the basket id increasing. Then once you finally add a product to your basket, the referrer should no longer be overwritten.

                If you go to the Cookie Settings tab in Domain, what is your Non-secure Miva Merchant Cookie Output set to?

                Thanks
                David Carver
                Miva, Inc. | Software Developer

                Comment

                • kwgarrett
                  Mivite

                  • Oct 2008
                  • 135

                  #9
                  Re: Need help with custom order field for relaying http-referer

                  It is set to Set only on HTTP connections, without secure flag. Anticipating further questions on this, I have included a screen shot of that admin panel.

                  Screen Shot 2013-12-13 at 9.34.51 AM.jpg

                  Thanks for your help. I do appreciate it.

                  Kevin

                  Comment

                  • dcarver
                    Director of Software Dev.




                    • May 2013
                    • 400

                    #10
                    Re: Need help with custom order field for relaying http-referer

                    Hi Kevin,

                    Upon further inspection it appears that your cookies are not being sent when loading your homepage with the rewritten URLs. When I go to http://www.podmerchant.com/mm5/merch...Store_Code=PM5 I then have a cookie set and my basket id does not change across every page load. When I go to http://www.podmerchant.com I get no cookie. We believe this may have something to do with a third party module you have installed, but no guarantees. I'd recommend opening a support ticket and they will be able to take a closer look into the issue.

                    Hope this helps.

                    Thanks
                    David Carver
                    Miva, Inc. | Software Developer

                    Comment

                    • kwgarrett
                      Mivite

                      • Oct 2008
                      • 135

                      #11
                      Re: Need help with custom order field for relaying http-referer

                      I submitted a ticket but I think I have found a possible solution. I found that when the referring site points to:



                      Instead of

                      Looking for a great E.S.E. Espresso Pod? Checkout out large selection for espresso coffees mostly from italy.


                      a basket cookie is set. I think the point is that it is missing the Store_Code=PM5.

                      I also see that some links to products are missing the store code. I'm going to try to fix all of those and see if that makes a difference.

                      Kevin Garrett

                      Comment

                      • kwgarrett
                        Mivite

                        • Oct 2008
                        • 135

                        #12
                        Re: Need help with custom order field for relaying http-referer

                        Upon further (& extensive) testing, I find it has nothing to do with a missing store code. Looked like it did for a minute there. I agree that it is simply the difference between use of the informative and SEO-friendly urls vs the ugly "real" urls. I use SSI to make those friendly URLs. Why the basket cookie is not being set when first accessing the store is the real question.

                        I have somewhat alleviated the problem in that I changed my feed to Amazon Product Ads, Google Adwords, and Google Shopping to use the ugly URLs. This enables the basket cookie to be set on referrals from those sources. However, I'd still really like to get this problem solved.

                        FYI, the SSI directives I am using look like this. I have an html stub file for every product and screen.

                        http://www.podmerchant.com/index.html —> <!--#include virtual="/mm5/merchant.mvc?Screen=SFNT&Store_Code=PM5" -->

                        Kevin Garrett

                        Comment

                        Working...
                        X