How can I assign a unique identifier for first-time visitors on a website?

Shopify Partner
3 0 1

Hi guys. Posting for the first time, so let me know if something is amiss.
I've been working on a puzzling task for a client of mine,  and can't seem to figure out a good way to do it.
My clients would like to provide a 50% off on all products to first time purchasers on their site(no matter if they're signed up customer or not).
So far, the best way I've been able to think of, is to create a cookie for all users who visit the site, and based on whether they purchased anything, modify said cookie.
I would be modifying the frontend to accommodate for this, and adding a specific line item property to each item added to cart if the cookie confirms the fact that they're a first time purchaser. This way, I can check for that property in a checkout script, and if it's present, apply a 50% OFF discount on checkout.

Obviously, this plan has a lot of caveats. The main one being a clever user could reset their browser and keep taking advantage of this offer by deleting the cookie.
Another one being, how do I make sure the user has purchased a product ? There doesn't seem to be any option to run some JavaScript when a transaction is processed.

I would appreciate input from you guys on what the best way to go about doing this would be, and any issues you see in this plan. Thanks.

Replies 3 (3)

Shopify Partner
252 20 35

Well if I am not entirely mistaken you should be able to do that out of the shopify box. 


1. Make a segment of customers who never bought anything so far


2. Make a discount available only to this segment. 


3. charge your customer for great consulting effort 🙂

> I hope you find my reply helpful. To let me know click on like!
> I'd love to help. Was your question answered? Mark it as an Accepted Solution
> WhatsApp: | Email:
Shopify Partner
3 0 1


Thank you so much for replying. Unfortunately, my clients are trying to target first time purchasers only, so they wouldn't have any accounts on the site to begin with, so we can't really do any kind of segmentation on them.
Shopify Partner
1807 143 189

Hi @darkAmdHa ,


You can add specific tag to every customer made successful purchase. On frontend check customer list via using their e-mail or phone number entered by user at time of checkout.


If user don't have specific tag in customer data apply discount coupon for them.


Hope this will resolve you query.

For any custom development WhatsApp or connect at Email ID: for quick consultation. | Shopify Free codes
To support Buy Me a Coffee