Hey all,
I’m trying to find out how I can tag a customer once they have ordered from a certain collection? I have collections setup, with unique URLs wich I’m relying heavily on to filter certain customers to certain groups. I’d like the tag these customers once they have purchased from a collection. Also note that specific products and across multiple collections. I really would like to just attach a tag to each Collection group.
Shopify support has said that I should create Segments, but I’m not sure if this is the right way to go about it. I can’t see how to automate tags for a segment group? I also thought this could be a Flow, but there doesn’t seem to be many Collection attributes on there.
Any ideas or suggestions?
1 Like
Hi @ckgdesign ,
I’m not familiar with how segments work for purchases from specific collections so I can’t speak to that.
But with Flow, you could achieve this using a Run code step that finds the collections and adds some aspect of the collection as a customer tag. I used the Collection title for this example, but you could store the tag value in a Collection metafield or use something else.
Here is the structure of the Workflow:
And here is the code step’s setup and code:
Input:
query{
order {
lineItems {
product {
collections {
title
}
}
}
}
}
Output:
"The output of Run Code"
type Output {
"The list of tags to add to the customer"
tags: [String!]
}
Code:
export default function main(input) {
const titles = input.order.lineItems.reduce((acc, lineItem) => {
const productTitles = lineItem.product.collections.map(collection => collection.title);
return [...acc, ...productTitles];
}, []);
// De-duplicate the titles so they can be used as tags
const uniqueTitles = [...new Set(titles)];
return {
tags: uniqueTitles,
}
}
Hope that helps get you started!
It sounds like you’re wanting to classify them based on the collection page they visited prior to checkout? Not based on the collection a product belongs to since some products belong to multiple?
This can be done by looking at the urls in the customer journey, but that generally only works off of the first url they land on, not every url they visit leading up to a purchase. I think you might need a custom pixel built to track the level of granularity you would need for that.
You can do that by creating an automation on Flow: when an order is created check if the collection title equals to x, then add customer tags.