Skip to content

Commit a6cfc83

Browse files
committed
Add UTM codes to placeholder links
1 parent fd5436b commit a6cfc83

File tree

1 file changed

+22
-4
lines changed

1 file changed

+22
-4
lines changed

includes/plugin-and-theme-hooks/class-gravityview-object-placeholder.php

Lines changed: 22 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -231,6 +231,9 @@ public function render(): void {
231231
}
232232

233233
$attributes = [ 'data-text-domain' => $this->text_domain ];
234+
235+
$buy_now_link = $this->get_buy_now_link_with_utms();
236+
234237
if ( self::STATUS_INACTIVE === $this->get_status() ) {
235238
$plugin = $this->get_plugin();
236239
$plugin_basename = $plugin['path'] ?? '';
@@ -243,20 +246,19 @@ public function render(): void {
243246
$caps = 'install_plugins';
244247
$attributes['data-action'] = 'install';
245248
$button_text = __( 'Install & Activate', 'gk-gravityview' );
246-
$button_href = $this->buy_now_link;
249+
$button_href = $buy_now_link;
247250
} else {
248251
$caps = 'read';
249252
$button_text = __( 'Buy Now', 'gk-gravityview' );
250-
$button_href = $this->buy_now_link;
253+
$button_href = $buy_now_link;
251254
}
252255

253-
$params = compact( 'caps', 'button_href', 'button_text', 'attributes' );
256+
$params = compact( 'caps', 'button_href', 'button_text', 'attributes', 'buy_now_link' );
254257
$params = array_merge( $params, [
255258
'type' => (string) $this->type,
256259
'icon' => (string) $this->icon,
257260
'title' => (string) $this->title,
258261
'description' => (string) $this->description,
259-
'buy_now_link' => (string) $this->buy_now_link,
260262
] );
261263

262264
// Render the template in a scoped function.
@@ -265,4 +267,20 @@ public function render(): void {
265267
require GRAVITYVIEW_DIR . 'includes/admin/metaboxes/views/placeholder.php';
266268
} )();
267269
}
270+
271+
/**
272+
* Returns the Buy Now link with UTM parameters added.
273+
*
274+
* @since TODO
275+
*
276+
* @return string The buy now link.
277+
*/
278+
private function get_buy_now_link_with_utms(): string {
279+
return add_query_arg( [
280+
'utm_source' => 'plugin',
281+
'utm_medium' => 'buy_now',
282+
'utm_campaign' => 'placeholders',
283+
'utm_term' => $this->text_domain,
284+
], $this->buy_now_link );
285+
}
268286
}

0 commit comments

Comments
 (0)