| @@ -88,8 +88,28 @@ | ||
| 88 | 88 | return $args; |
| 89 | 89 | } |
| 90 | 90 | |
| 91 | 91 | /** |
| 92 | + * Campaign tags for links into the shop. | |
| 93 | + * | |
| 94 | + * forge12.com runs WooCommerce, whose Order Attribution stores the utm_* | |
| 95 | + * parameters a buyer arrived with on the order. `from` alone only shows up in | |
| 96 | + * server logs; these make a sale traceable to the place in the plugin that led | |
| 97 | + * to it. Product links only — a feedback or support visit is not a sale. | |
| 98 | + * | |
| 99 | + * @param string $from Which entry point the click came from. | |
| 100 | + * | |
| 101 | + * @return array<string, string> | |
| 102 | + */ | |
| 103 | +function campaign_args( string $from ): array { | |
| 104 | + return array( | |
| 105 | + 'utm_source' => 'double-opt-in', | |
| 106 | + 'utm_medium' => 'plugin', | |
| 107 | + 'utm_campaign' => $from !== '' ? $from : 'unspecified', | |
| 108 | + ); | |
| 109 | +} | |
| 110 | + | |
| 111 | +/** | |
| 92 | 112 | * Build a link to the product page. |
| 93 | 113 | * |
| 94 | 114 | * @param string $from Which entry point the click came from. |
| 95 | 115 | * |
| @@ -95,9 +115,9 @@ | ||
| 95 | 115 | * |
| 96 | 116 | * @return string |
| 97 | 117 | */ |
| 98 | 118 | function get_product_url( string $from = '' ): string { |
| 99 | - $url = add_query_arg( link_args( $from ), PRODUCT_BASE . PRODUCT_PATH ); | |
| 119 | + $url = add_query_arg( link_args( $from ) + campaign_args( $from ), PRODUCT_BASE . PRODUCT_PATH ); | |
| 100 | 120 | |
| 101 | 121 | /** |
| 102 | 122 | * Filter a link to the product site. |
| 103 | 123 | * |