PMC Trackonomics
Introduction
This plugin implements the functionality to to wrap all identified affiliate links with a Trackonomics (TRX) redirect wrapper to ensure tracking. (See BR-1993)
When a post is saved, the post content is searched for affiliate links using a list of regex patterns fetched from the Trackonomics API. Then, all of the identified affiliate links are saved as an array to post meta. When the post content is rendered, the post meta is used to identify which links to wrap in the redirect wrapper (only when the plugin is enabled via Cheezcap settings).
The original implementation was to do all of this on render (on the_content filter) but this caused performance issues when loading the page due to one of the regex patterns being over 25,000 characters long.
The following are the steps to launching this functionality on a brand.
-
Open and merge a PR to load plugin for selected brand.
-
Configure theme settings (using the below access credentials and codes), fetch detection keys and enable the plugin.
After you input all of the settings, you must click 'Save' (to save those settings to the dB) before you will be able to fetch the detection keys successfully.
-
Run the following command on a VIP Staging site and confirm that the run completes successfully. It is recommended to copy the database from prod prior to doing this step so you have the most recent data. Keep in mind that you will also need to configure the settings on the staging site (as done in the previous step).
wp pmc-trackonomics generate --overwrite --no-dry-run(see WP-CLI section)
- Review the staging site for posts that have affiliate links and confirm that they are being wrapped with the redirect wrapper. Use the following WP-CLI command to generate a list of posts that have affiliate links. Adjust the range argument as needed.
wp pmc-trackonomics view --range="-30 days"
- Open VIP ticket to have them run the above CLI command and have them save the command output to verify changes.
- Use the command output to verify that link wrapping is happening for posts with affiliate links.
- Let Product Manager know and confirm that the Trackonomics team has been notified.
Note: It's best to run the CLI script only after the plugin is enabled to prevent the possiblity of an affiliate link post being published without the needed post meta.
WP-CLI Custom Commands
There are currently 2 custom commands available to aid this plugin.
wp pmc-trackonomics generate
The wp pmc-trackonomics generate command searches through all posts and, if affiliate links are found, generates the associated post meta.
wp pmc-trackonomics view
The wp pmc-trackonomics view command searches through all posts in the last 30 days and displays a list of those that have affiliate links.
See [insert file path] for more details on how these commands work and their available arguments.
Access Credentials & Codes
Environment Code
This will be the same for all brands as they should be under the same pmc environment account in Trackonomics.
| Env Code |
|---|
pmc_0aaa4 |
System Token
Can be found when logging into the Trackonomics dashboard.
| System Token |
|---|
MziT0dpHLkYglrsFLtbIGG4KucrShY4YGpWvr2GH |
Site Codes
| Site | Site Code |
|---|---|
Spy | pmc_0aaa4_spy |
Rolling Stone | pmc_0aaa4_rollingstone |
Stylecaster | pmc_0aaa4_stylecaster |
Sheknows | pmc_0aaa4_sheknows |
Footwearnews | pmc_0aaa4_footwearnews |
BGR | pmc_0aaa4_bgr |
Robbreport | pmc_0aaa4_robbreport |
WWD | pmc_0aaa4_wwd |
Variety | pmc_0aaa4_variety |
Hollywoodlife | pmc_0aaa4_hollywoodlife |
Billboard | pmc_0aaa4_billboard |
Artnews | pmc_0aaa4_artnews |
Indiewire | pmc_0aaa4_indiewire |
The Hollywood Reporter | pmc_0aaa4_thehollywoodreporter |
Vibe | pmc_0aaa4_vibe |
TV Line | pmc_0aaa4_tvline |
Login Credentials
Credentials for logging into the Trackonomics dashboard.
| Password | |
|---|---|
[email protected] | *(03PWH1 |
Available Filters
pmc_trackonomics_wrap_affiliate_link
Use this filter to wrap a given url with a TRX redirect wrapper. This mostly applies to theme code that might render affiliate links outside of the post content (i.e. header, sidebar, etc.)
$affiliate_url = apply_filters( 'pmc_trackonomics_wrap_affiliate_link', $affiliate_url );