onclick set a variable for collection

18 0 2

Hi there,  Just need some help with variables

I have a page that I want customers to click one of two options.  To subscribe or not.  When they click the link the collection page will open where they can select products. 

one the collection page I want a variable

{% when 1 %}
  {% assign buy_type = one-off %}
{% when 2 %}
  {% assign buy_type = subscribe %}

If they click "One-off order" I want the variable be "1" on the collection page, If they click subscribe I want the variable top be "2"

Can someone tell me how this can be achieved?