---
updatedAt: 2026-10-08T09:18:29.000Z
agentTools:
  siteIndex: https://documentation.bloomreach.com/llms.txt
  projectIndex: https://documentation.bloomreach.com/engagement/llms.txt
---

# Buyapowa

Integrate Buyapowa in Bloomreach using [Omniconnect](https://documentation.bloomreach.com/engagement/docs/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 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. Go to `Data & Assets > Integrations > +Add new integration`

[block:image]
{
  "images": [
    {
      "image": [
        "https://files.readme.io/cab1f4f-1.png",
        "",
        ""
      ],
      "align": "center",
      "sizing": "500px"
    }
  ]
}
[/block]

2. Find *Omniconnect* and click on `+ Add integration`
3. Rename the integration and click on `Save integration`
4. Go to the `Transformation` tab
5. Paste the [transformation function](https://documentation.bloomreach.com/engagement/docs/buyapowa#transformation-function) and click on `Save changes`

[block:image]
{
  "images": [
    {
      "image": [
        "https://files.readme.io/d62ea66-2.png",
        "",
        ""
      ],
      "align": "center",
      "sizing": "500px"
    }
  ]
}
[/block]

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

[block:image]
{
  "images": [
    {
      "image": [
        "https://files.readme.io/b887580-3.png",
        "",
        ""
      ],
      "align": "center",
      "sizing": "400px"
    }
  ]
}
[/block]

## 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