Skip to content

Commit

Permalink
Merge pull request #297 from razorpay/1cc-fb-utm
Browse files Browse the repository at this point in the history
[PLG-245] Fixed UTM param issue
  • Loading branch information
ChetanGN authored Jun 16, 2022
2 parents 64077c5 + 25fea2f commit 2a41f76
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 4 deletions.
3 changes: 3 additions & 0 deletions btn-1cc-checkout.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@ window.addEventListener('DOMContentLoaded', function() {
var pageURL = jQuery(location).attr('href');
var url = new URL(pageURL);
var accessToken = new URLSearchParams(url.search).get('wcf_ac_token');
var referrerDomain = document.referrer.toString();

rzp1ccCheckoutData.referrerDomain = referrerDomain;

// event triggered by wc on any cart change
// as input function is the same, duplicate event listeners are NOT called
Expand Down
12 changes: 11 additions & 1 deletion includes/api/order.php
Original file line number Diff line number Diff line change
Expand Up @@ -274,11 +274,21 @@ function wooSaveCheckoutUTMFields($orderId, $params)
{
$pysData = [];
$cookieData = $params['cookies'];
$getQuery = $params['requestData'];
$browserTime = $params['dateTime'];
$pysData['pys_landing'] = isset($cookieData['pys_landing_page']) ? ($cookieData['pys_landing_page']) : "";
$pysData['pys_source'] = isset($cookieData['pysTrafficSource']) ? ($cookieData['pysTrafficSource']) : "direct";
if($pysData['pys_source'] == 'direct')
{
$pysData['pys_source'] = $params['referrerDomain'] != '' ? $params['referrerDomain'] : "direct";
}
$pysUTMSource = $cookieData['pys_utm_source'] ?? $getQuery['utm_source'];
$pysUTMMedium = $cookieData['pys_utm_medium'] ?? $getQuery['utm_medium'];
$pysUTMCampaign = $cookieData['pys_utm_campaign'] ?? $getQuery['utm_medium'];
$pysUTMTerm = $cookieData['pys_utm_term'] ?? $getQuery['utm_term'];
$pysUTMContent = $cookieData['pys_utm_content'] ?? $getQuery['utm_content'];

$pysData['pys_utm'] = "utm_source:" . $cookieData['pys_utm_source'] . "|utm_medium:" . $cookieData['pys_utm_medium'] . "|utm_campaign:" . $cookieData['pys_utm_campaign'] . "|utm_term:" . $cookieData['pys_utm_term'] . "|utm_content:" . $cookieData['pys_utm_content'];
$pysData['pys_utm'] = "utm_source:" . $pysUTMSource . "|utm_medium:" . $pysUTMMedium . "|utm_campaign:" . $pysUTMCampaign . "|utm_term:" . $pysUTMTerm . "|utm_content:" . $pysUTMContent;
$pysData['pys_browser_time'] = $browserTime[0] . "|" . $browserTime[1] . "|" . $browserTime[2];

update_post_meta($orderId, "pys_enrich_data", $pysData);
Expand Down
5 changes: 4 additions & 1 deletion readme.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ Contributors: razorpay
Tags: razorpay, payments, india, woocommerce, ecommerce
Requires at least: 3.9.2
Tested up to: 5.9
Stable tag: 3.8.2
Stable tag: 3.8.3
Requires PHP: 5.6
License: GPLv2 or later
License URI: http://www.gnu.org/licenses/gpl-2.0.html
Expand Down Expand Up @@ -41,6 +41,9 @@ This is compatible with WooCommerce>=2.4, including the new 3.0 release. It has

== Changelog ==

= 3.8.3 =
* Bug fix for UTM data for pixel your site plugin for magic checkout.

= 3.8.2 =
* Bug fix for blog name in magic checkout.

Expand Down
5 changes: 3 additions & 2 deletions woo-razorpay.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
* Plugin Name: Razorpay for WooCommerce
* Plugin URI: https://razorpay.com
* Description: Razorpay Payment Gateway Integration for WooCommerce
* Version: 3.8.2
* Stable tag: 3.8.2
* Version: 3.8.3
* Stable tag: 3.8.3
* Author: Team Razorpay
* WC tested up to: 6.4.1
* Author URI: https://razorpay.com
Expand Down Expand Up @@ -1929,6 +1929,7 @@ function enqueueScriptsFor1cc()
'siteurl' => $siteurl,
'blogname' => get_bloginfo('name'),
'cookies' => $_COOKIE,
'requestData' => $_REQUEST,
) );
wp_enqueue_script('btn_1cc_checkout');
}
Expand Down

0 comments on commit 2a41f76

Please sign in to comment.