Integrate Buyapowa in Bloomreach Engagement using Omniconnect! Buyapowa allows customers to refer their friends with a unique referral link, which enables Bloomreach to capture the information of the referred “friend” to obtain a new customer.

This integration also properly assigns consent events to the friend if they have accepted marketing.

How to set it up

🚧

Prerequisites

  • A Bloomreach Engagement project with integration access
  • A Buyapowa account
  • Contact with a Buyapowa Account Manager to apply the webhook URLs on their side
  • Your project email identifier

1. Create the integration

  1. In Bloomreach Engagement, go to Data & Assets > Integrations > +Add new integration
  1. Find Omniconnect and click on + Add integration
  2. Rename the integration and click on Save integration
  3. Go to the Transformation tab
  4. Paste the transformation function and click on Save changes
  1. Update the email_id parameter with the email identifier in your project.

2. Set up the webhook

  1. Go back to the Settings tab
  2. Copy the Omniconnect URL
  3. Send the Omniconnect URL to the Buyapowa Account Manager
  4. Generate a test referral and follow the process through as the "friend"

3. Configure the transformation function

The transformation function contains 1 declared variable

  1. Update the email_id variable according to the email customer identifier in your project
  2. Click on Test transformation and check the result

Transformation function

This function takes the input from Buyapowa’s webhook and generates the required events and customer properties.

Update the email_id parameter with the email identifier in your project.

const email_id = "email_address"
/**
* Handler is the entry point for the function that enables the transformation of the data.
* @param data
* @returns {*}
*/
function handler(data) {
	const batch_payload = 
	[ {
        "name": "customers/events",
        "data": {
            "event_type": "buyapowa_friend_registration",
            "customer_ids": {
                email_id: data.friend.email
            },
            "timestamp": Math.round(Date.now()/1000),
            "properties": {
            	"action": "register",
                "voucher": data.friend.voucher.code
            }
        }
    },{
        "name": "customers",
        "data": {
            "customer_ids": {
                email_id: data.friend.email
            },
            "properties": {
                "email": data.friend.email,
                "first_name": data.friend.first_name,
                "last_name": data.friend.last_name
            },
		    "update_timestamp": Math.round(Date.now()/1000)
        }
    }]
    
    if(data.friend.marketing_opt_in) {
    	batch_payload.push({
        "name": "customers/events",
        "data": {
            "event_type": "consent",
            "customer_ids": {
                email_id: data.friend.email
            },
            "timestamp": Math.round(Date.now()/1000),
            "properties": {
                "action": "accept",
                "category": "newsletter",
                "valid_until": "unlimited"
            }
        }})
    }
    
    return batch_payload;
}

Troubleshooting

  • If the data doesn’t appear against a customer profile, make sure that email_id is set correctly
  • Ensure that you have followed the flow in Buyapowa from start to finish and that you’re using a new, unique link each time
    • The link retains whether you’ve already submitted it