Articles on: Integrations

Shopify Metafields

In Shopify, metafields are a way to add custom fields to your store's data. They allow you to store additional information in Shopify's data structure. With this integration, Nector will be able to push any loyalty related data to that customer's metafield on Shopify.

Accessing a customer's loyalty data from Shopify customer metafield has a few benefits like:
Create your own UI for showing the loyalty data of customers, without having to rely on APIs
Avoid API calls to fetch the loyalty data
Conditionally render certain sections in your theme's liquid file based on the loyalty data stored in the metafields

Please note that although we update the customer's metafields in real time, sometimes the data might not be up to date due to Shopify APIs rate limit.

To enable and configure the syncing to Shopify metafields, follow the below steps.

First go to Integrations Page and click on Theme Metafields in the side-bar then click on Configure button in Shopify Metafield




In the new page, toggle the Status button to activate the integration. It will look like the below image.




Switch to the Events tab and click on Create An Event




It opens up to the Events page with the Send Events tab and click on "+" button

For "Event" option, select Customer is Updated
For "Send event to" option, by default Shopify Metafield will be selected.

For the Event only “Customer Signsup” and “Customer is Updated” events are supported however it is recommended to use the "Customer is Updated" option.

Click on Create button




Shopify metafield integration is successfully set up.

To know more about how to manage the events, refer to this article: Events


Nector syncs the data to shopify customer metafield as a single JSON field. This is the format and fields that Nector syncs:




{
  "nector_user_name": "Yashas",
  "nector_user_tier": "silver",
  "nector_user_type": "member",
  "nector_user_referral_code": "jff0hzqxv4",
  "nector_user_referral_coupon_code": "necbrefiwfiwoijf",
  "nector_user_referral_link": "https://nector-dev-store-2.myshopify.com/?referral_code=jff0hzqxv4&utm_source=nector&utm_medium=event&utm_campaign=transactional",
  "nector_user_new_referral_link": "https://nector-dev-store-2.myshopify.com/?nector_referral_code=jff0hzqxv4&utm_source=nector&utm_medium=event&utm_campaign=transactional",
  "nector_user_balance": 5222,
  "nector_user_available_balance": 5222,
  "nector_user_dob": "16-01",
  "nector_user_full_dob": "16-01-2013",
  "nector_user_country": "ind",
  "nector_user_transaction_amount": 95338.93
}



To access the metafields in your liquid code, you will need to use the below key:

{{ customer.metafields.nector.custom_properties.value }}

For example, to access the available balance of the customer, your code in the liquid file should look like this:

{{ customer.metafields.nector.custom_properties.value.nector_user_balance }}

Updated on: 22/07/2024

Was this article helpful?

Share your feedback

Cancel

Thank you!