Record Judge.me customer review counts
Using Judge.me for reviews? Use this task to keep a counter for each customer's reviews, stored as a metafield on the customer record. And, auto-tag customers as they reach different levels of review counts - useful for granting discounts or special access to repeat reviewers.
Try this taskWhen it runs
Occurs when a Judge.me review is created
What you choose
- Metafield namespace
- Metafield key
- Tags to apply for review counts
Documentation
Using Judge.me for reviews? Use this task to keep a counter for each customer's reviews, stored as a metafield on the customer record. And, auto-tag customers as they reach different levels of review counts - useful for granting discounts or special access to repeat reviewers.
After installing this task, activate Judge.me's Mechanic integration: Settings > Integrations > Admin Backend > Mechanic.
Notes:
- This task will start counting reviews for each customer, as each review comes in. It will not scan reviews that existed beforehand.
- Reviews will only be attributed to a customer account if (a) the customer is already registered, and (b) the reviewer submits the correct customer email address in the review form.
Task code and subscriptions
You can edit the Liquid code after installing this task. View on GitHub or ask a question in the Mechanic Slack community.
Subscriptions
judgeme/review/created
How task subscriptions work
Option types and flags
- Metafield namespace (required)
- Metafield key (required)
- Tags to apply for review counts (keyval)
Task code
{% assign metafield_namespace = options.metafield_namespace__required %}
{% assign metafield_key = options.metafield_key__required %}
{% assign customer = shop.customers[review.reviewer.external_id] %}
{% if event.preview %}
{% capture customer_json %}
{
"admin_graphql_api_id": "gid://shopify/Customer/1234567890",
"metafields": [
{
"namespace": {{ metafield_namespace | json }},
"key": {{ metafield_key | json }},
"value": 0
}
]
}
{% endcapture %}
{% assign customer = customer_json | parse_json %}
{% endif %}
{% if customer %}
{% assign current_review_count = customer.metafields[metafield_namespace][metafield_key].value | default: 0 %}
{% assign next_review_count = current_review_count | plus: 1 %}
{% assign next_review_count_as_string = next_review_count | append: "" %}
{% assign tag = options.tags_to_apply_for_review_counts__keyval[next_review_count_as_string] %}
{% action "shopify" %}
mutation {
metafieldsSet(
metafields: [
{
ownerId: {{ customer.admin_graphql_api_id | json }}
namespace: {{ metafield_namespace | json }}
key: {{ metafield_key | json }}
value: {{ next_review_count_as_string | json }}
type: "number_integer"
}
]
) {
metafields {
id
namespace
key
type
value
owner {
... on Customer {
id
}
}
}
userErrors {
code
field
message
}
}
{% if tag != blank %}
tagsAdd(
id: {{ customer.admin_graphql_api_id | json }}
tags: {{ tag | json }}
) {
node {
id
}
userErrors {
field
message
}
}
{% endif %}
}
{% endaction %}
{% endif %}
Mechanic Liquid reference