Node "Share Data"

The “Share Data” node, an action-type node, is used to send data from a previous "Get Products" node. Its use allows receiving product data to be used for different purposes by the client. For example, it is possible to integrate it with native eCommerce components to display recommended products without requiring the use of a Web Content.

 

Using the “Share Data” node will consume one Store activity each time it is executed for each contact.

  

To configure this node, you will need an expert with programming knowledge.

 

How to access it?

In your workflows, drag the "Share Data" node from the right menu to the design area. You can access its configuration by clicking  (Edit node configuration).

Share Data Node - 1-min.png

 

Interface

The main interface of the "Share Data" node is composed of three blocks:

1. Identifier: to enter a term that identifies the node and, later, to retrieve the data in the eCommerce using that identifier.

2. Source node: to indicate to Connectif from which node to get the data. It can only be a source node of the “Get Products” type.

 

If a "Get Products" node is not placed before the "Share Data" node, the selector will appear empty and the interface will display an error alert.

3. Source node fields: to select which fields we want to receive. Fields shown in grey are
mandatory and cannot be deselected.

Share Data Node - 2-min.png

 

Functionality

Action-type nodes are those that execute specific operations within flows. The “Share Data” node is used to send data to the eCommerce from a previous "Get Products" node. Its use allows receiving product data to later be used on the client side as desired.

One of its most common uses is to customize native components to display personalized products to the contact from a workflow without needing to use Web Content. Especially useful in VTEX integrations.

 

The "Get Products" node passes product data to the "Share Data" node, which is responsible for sending it to the eCommerce.

It works similarly to the Connectif "Show Web Content" node, with the difference that the data is not shown on the website, but retrieved through the assigned identifier and sent in the scrippet's response.

 

1. Using the node in a workflow to share data

The "Share Data" node can be used within a workflow exactly like a "Show Web Content" node, with the difference that, in this case, no content is displayed on the page but the eCommerce receives the data to later use it as desired.

In the following example, it is used along with the "On Page Visit" trigger to extract visited products and send them to the eCommerce.

 

If you want to execute data retrieval multiple times per customer, it is necessary to disable the limitations of the "On Page Visit" and "Share Data" nodes in the workflow.

Share Data Node - 3-min.png

 

2. Configuration of the "Share Data" node

In the node interface, assign an Identifier (1) to later retrieve the node’s data (section 3).

Share Data Node - 4-min.png

Select the Source Node (2), which must always be a "Get Products" node, from which the product information shared in this "Share Data" node will be extracted.

Share Data Node - 5-min.png

Choose the Fields from the source node (3), to select which product information will be shared with the eCommerce.

Share Data Node - 6-min.png

 

3. Retrieving node data for use in the eCommerce

Once the node is configured and the workflow activated, to retrieve this data in the eCommerce and later use it in native components, the following function must be used:

const identifier = "academy-example";
const sharedData = window.connectif.managed.getSharedDataById(identifier);

In this function, the "identifier" must always match the one set in the "Share Data" node. Following our example with identifier "academy-example", once retrieved, the code might look like this:

const identifier = "academy-example";

const getAndProcessSharedData = (identifier) => {
  const sharedData = window.connectif.managed.getSharedDataById(identifier);
  if (sharedData && sharedData.products.length > 0) {
    // process the data found according to need
  }
};

const handleSharedDataReceivedEvent = (event) => {
  if (event?.detail?.id === identifier) {
    getAndProcessSharedData(identifier);
  }
};

document.addEventListener(
  "connectif.managed.shared_data_received",
  handleSharedDataReceivedEvent
);

if (
  window.connectif &&
  window.connectif.managed
) {
  getAndProcessSharedData(identifier);
}  
 

Success! 
You’ve reached the end of the lesson.

  

Still have unresolved questions? 
Remember, our Connectif specialists are here to help. To contact them, just open a support ticket by clicking the blue “Help” button on your dashboard.

 


Keep learning!

To make the most of your Connectif account, we recommend continuing with the following articles: