Signature
$url = apply_filters( 'mam_universal_link_get_branch_link', $campaign, $channel, $feature, $stage, $data );
| Parameter | Type | Description |
|---|---|---|
$campaign |
string|null |
Branch campaign label, e.g. 'contact-invite', 'new_product'. |
$channel |
string|null |
Branch channel, e.g. 'email'. |
$feature |
string|null |
Branch feature label. |
$stage |
string|null |
Branch stage label. |
$data |
array|null |
Deep-link payload delivered to the app after open/install. Branch control keys like $desktop_url (web fallback) work here. |
Returns the Branch URL (string), or '' when no Branch key is configured or the API call fails — always handle the empty case with a fallback URL.
Behavior
- Uses the test key when Use Test Keys is checked on the Universal Link settings page, otherwise the live key.
- Calls
POST https://api2.branch.io/v1/urlserver-side (15 s timeout); errors are logged via the MAM debug log and return''. - Each call creates a fresh link (unique alias) — cache the result if you mint per-object links (the contact-invite integration caches per invite in post meta
branch_invite_url).
Example
$data = array(
'listing_id' => $post_id,
'$desktop_url' => get_permalink( $post_id ),
);
$link = apply_filters( 'mam_universal_link_get_branch_link', 'new_listing', 'share', null, null, $data );
if ( '' === $link ) {
$link = get_permalink( $post_id ); // Branch unavailable — fall back
}
(MAM GeoDirectory uses exactly this shape for new-listing links.)
Related hooks
mam_universal_link_enabled— feature-detection filter; this plugin forces it totrueso other plugins (e.g. MAM GeoDirectory) know a universal-link provider is active.mam_invite_link(MAM Main) — this plugin consumes it to upgrade contact-invite links to Branch links automatically.
Related articles
- Set up Branch.io deep links
Metadata
| Field | Value |
|---|---|
| Article type | Hook Reference |
| Plugin slug | mam-universal-link-manager |
| Applies to plugin version | 26.24.1+ |
| Category | Extending MAM Suite |
| Hook type | filter (used as a factory) |
| Audience | PHP developer |
| Last verified | 2026-06-12 |
