skip to Main Content

If a customer lands on any page of the Shopify site (not Plus), with a referral parameter in GET (?ref=something), how can this value be carried over to the checkout and order confirmation pages, where the domain is different?

One idea I had was to set a cookie on our domain, and then modify URL one navigates to upon clicking Checkout to include the values of the cookies, but I am unsure if this is the cleanest way, and where the best place to modify the URL would be.

I see that _ga parameter appears to be included automatically, in checkout URL. How can this be done for custom GET parameters?

2

Answers


  1. One is the tricky way for doing this by modifying the checkout URL before submitting.

    For doing this on your cart.liquid file find the form with action=”/cart” and add attribute:

    onsubmit="update_action(this)"
    

    And add the javascript code at the bottom of your theme.liquid file :

    <script type="text/javascript">
     function update_action(form){
       var new_action; 
       var some_value = "something";
       var form_action = form.action;
       if( (form_action.indexOf("?") >= 0) ) {
         if(form_action.indexOf("ref")>=0) {
           new_action = form_action.replaceAt(form_action.indexOf("ref"),"ref="+some_value);
         }else{
           new_action = form_action+"&ref="+some_value;
         }
       }else{
         new_action = form_action+"?ref="+some_value;
       }
       $(form).attr("action",new_action);
     }
    </script>
    

    Hope this will solve your problem.

    Login or Signup to reply.
  2. Note that the ref and landing page are automatically stored by Shopify, meaning without you doing anything, you get those values in the order placed by the customer. You do not have manually manipulate them as per this thread.

    Why do you need the value on checkout (you can do nothing with it anyway) and why on the order confirmation where again, it serves no purpose for the customer?

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search