0

I have very basic knowledge of .liquid language.

In a Shopify store my client wants to give two adds on Facebook and She wants when a visitor come from Facebook adds they will see two different hero image in her home page.

For example. If a visitor come from facebook add 1 then he/she will see hero image slider 1 and If a visitor come from facebook add 2 then he/she will see hero image slider 2.

Is it possible?

Thanks in advance!

1 Answers1

0

Assuming that you know what ad they're coming from, you will be able to handle the switch in the controller. Note, this example assumes img2.jpg is the fallback but you may want to muddle with the logic.

def controller_action
  @hero_image = params[:ad_indicator].to_s == "ad1" ? "img1.jpg" : "img2.jpg"
end

Then in your page

<image src="#{@hero_image}" />

If you want that image to stay the same every time they are on that page, load it into a session variable.

Controller:

session[:hero_img] = @hero_image unless @hero_image.blank?

View:

<image src="#{@session[:hero_img] || `default.jpg`}" />

If you don't know what ad they're coming from, you'll need to figure out how to get that parameter passed in the url/request. Sounds like that's not the issue here though.

James Klein
  • 612
  • 4
  • 15
  • Hi @JamesKlein I'm really happy to have your reply. As I told you I'm very beginner in .liquid. It'll be great if you want to see the code. Please tell which code should I share with you? Thanks! – Shafiqul Islam Feb 25 '16 at 13:09