Auto-tag new customers with the current date, with Mechanic.

Mechanic is a development platform for Shopify. :)

Auto-tag new customers with the current date

by Isaac Bowen (team@usemechanic.com)

Use this task to tag incoming customers with the current date/time, using the format of your choice, and optionally a prefix and suffix.

Runs when a customer is created and when a customer is created. Configuration includes tag date format, tag prefix, tag suffix, and wait until the customer is enabled.

15-day free trial – unlimited tasks

Documentation

Use this task to tag incoming customers with the current date/time, using the format of your choice, and optionally a prefix and suffix. If you like, enable "Wait until the customer is enabled" to apply the tag when the customer's online account is activated, rather than when the customer is first created.

To customize the date/time format, use an "strftime" reference, like www.strfti.me.

Developer details

Mechanic is designed to benefit everybody: merchants, customers, developers, agencies, Gurus, everybody.

That’s why we make it easy to configure automation without code, why we make it easy to tweak the underlying code once tasks are installed, and why we publish it all here for everyone to learn from.

Events
when a customer is created (shopify/customers/create)
when a customer is created (shopify/customers/create)
Options
tag date format (required), tag prefix, tag suffix, wait until the customer is enabled (boolean)
Script
{% assign tag = "now" | date: options.tag_date_format__required | prepend: options.tag_prefix | append: options.tag_suffix %}

{% if event.preview %}
  {% assign customer = hash %}
  {% assign customer["admin_graphql_api_id"] = "gid://shopify/Customer/12345" %}
{% endif %}

{% action "shopify" %}
  mutation {
    tagsAdd(
      id: {{ customer.admin_graphql_api_id | json }}
      tags: {{ tag | json }}
    ) {
      userErrors {
        field
        message
      }
    }
  }
{% endaction %}
Mechanic tasks are written in Liquid, which makes them easy to write and easy to modify. Learn more about our platform.
Defaults
Tag date format
%Y%m%d
Tag prefix
signup-