Skip to main content

CustomerSegmentTemplate

CustomerSegmentTemplate is used to configure a template rendered in the Customers section of the Shopify admin. Templates can be applied in the customer segment editor and used to create segments.

Anchor to customersegmenttemplatepropsCustomerSegmentTemplateProps

string | string[]
required

The localized description of the template. An array can be used for multiple paragraphs.

string
required

The code snippet to render in the template with syntax highlighting. The query is not validated in the template.

string
required

The localized title of the template.

string

ISO 8601-encoded date and time string. A "New" badge will be rendered for templates introduced in the last month.

{ standardMetafields?: "facts.birth_date"[]; customMetafields?: string[]; }

The list of customer standard metafields or custom metafields used in the template's query.

string

The code snippet to insert in the segment editor. If missing, query will be used. The queryToInsert is not validated in the template.

Was this section helpful?

Simple CustomerSegmentTemplate implementation

import React from 'react';
import {reactExtension, CustomerSegmentTemplate} from '@shopify/ui-extensions/admin';

function App() {
return (
<CustomerSegmentTemplate
title="My Customer Segment Template"
description="Description of the segment"
query="number_of_orders > 0"
createdOn={new Date('2023-01-15').toISOString()}
/>
);
}

export default reactExtension('Playground', () => <App />);

Preview