Support Home > Jetpack affiliate code

Jetpack affiliate code

An affiliate code is a string or numbers and letters added to URLs on your site. The code is unique to you and allows Jetpack to track who clicks on these links and what purchases they make, so you can be credited. You can use your affiliate code with a few different kinds of links:

  • The URL in buttons that people click to set up Jetpack.
  • The URLs in banners that display in the Jetpack Admin UI that prompt people to upgrade to get access to a particular feature or an enhanced version of a feature
  • The URLs in what we call, JITMs, or Just In Time Messages: snippets of text accompanied by a linked button that appear when sometime performs a particular task (e.g., uploading an image) or enters a particular screen (e.g., visiting the Upgrade screen). These highlight Jetpack a feature they might be interested in or that empowers them to do more in that area.

There are two ways to make this code available on a website for Jetpack to read.

Setting up an option

The first way is to save a WordPress option in the database. If a partner can provision websites and run WP CLI commands, they can also issue the following command:

wp option add jetpack_affiliate_code abc123

Adding a filter

Other partners, like agencies that don’t have as much control for executing WP CLI commands, can add a filter. Here’s the necessary code, provided as a plugin. We recommend adding that this plug to the /wp-content/mu-plugins folder in the site -– if the folder doesn’t exist, create it:

<?php
/**
 * Plugin Name: Jetpack affiliate code
 */

/**
 * Return the affiliate code.
 *
 * @return string 
 */
function jp_custom_affiliate_code() {
    return 'abc123';
}

add_filter( 'jetpack_affiliate_code', 'jp_custom_affiliate_code' );

Which approach takes precedence?

Since there are two approaches Jetpack uses to read an affiliate code, you may wonder: which method takes precedence? The filter will take precedence over the option. If the affiliate code is set using jetpack_affiliate_code option and a filter is also applied, we will use the affiliate code returned from the filter.

  • Table Of Contents

  • Categories

  • Contact Us

    Need more help? Feel free to contact us.