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 scroll to find the Shopify Metafield and click on Configure button.




In the new page, click on Initialize button to activate the integration. It will look like the below image.




Go to Events Page. Make sure to Enable the Status button if its not already enabled.




Switch to Send Events and click on Create button

For "Event" option, select Customer is updated
For "Send event to" option, select Shopify Metafield

Click on Create button




Shopify metafield integration is successfully set up.


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_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/03/2024

Was this article helpful?

Share your feedback

Cancel

Thank you!