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:
I am testing this with the following code at the bottom of pages:
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
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>
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
Comment