Version Description
Download this release
Release Info
Developer | PixelYourSite |
Plugin | PixelYourSite – Facebook Pixel (Events, WooCommerce & Easy Digital Downloads) |
Version | 8.0.4 |
Comparing to | |
See all releases |
Code changes from version 8.0.3 to 8.0.4
- dist/scripts/public.js +103 -29
- facebook-pixel-master.php +1 -1
- includes/class-events-manager.php +25 -15
- modules/facebook/facebook.php +19 -5
- modules/facebook/function-helpers.php +35 -21
- modules/google_analytics/ga.php +51 -23
- pixelyoursite.php +1 -1
- readme.txt +11 -1
dist/scripts/public.js
CHANGED
@@ -215,6 +215,10 @@ if (!Array.prototype.includes) {
|
|
215 |
* PUBLIC API
|
216 |
*/
|
217 |
return {
|
|
|
|
|
|
|
|
|
218 |
fireEventForAllPixel:function(functionName,events){
|
219 |
if (events.hasOwnProperty(Facebook.tag()))
|
220 |
Facebook[functionName](events[Facebook.tag()]);
|
@@ -969,7 +973,7 @@ if (!Array.prototype.includes) {
|
|
969 |
if (window.pysWooProductData.hasOwnProperty(product_id)) {
|
970 |
if (window.pysWooProductData[product_id].hasOwnProperty('facebook')) {
|
971 |
event = Utils.copyProperties(event, {})
|
972 |
-
Utils.copyProperties(window.pysWooProductData[product_id]['facebook'], event.params)
|
973 |
this.fireEvent(event.name, event);
|
974 |
}
|
975 |
}
|
@@ -984,16 +988,53 @@ if (!Array.prototype.includes) {
|
|
984 |
if (window.pysWooProductData.hasOwnProperty(product_id)) {
|
985 |
if (window.pysWooProductData[product_id].hasOwnProperty('facebook')) {
|
986 |
|
987 |
-
if (product_type === PRODUCT_VARIABLE && !options.facebook.wooVariableAsSimple) {
|
988 |
product_id = parseInt($form.find('input[name="variation_id"]').val());
|
989 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
990 |
|
991 |
-
|
|
|
|
|
|
|
992 |
|
993 |
// maybe customize value option
|
994 |
if (options.woo.addToCartOnButtonValueEnabled && options.woo.addToCartOnButtonValueOption !== 'global') {
|
995 |
|
996 |
-
if(product_type ===
|
|
|
|
|
997 |
var data = $(".bundle_form .bundle_data").data("bundle_form_data");
|
998 |
var items_sum = getBundlePriceOnSingleProduct(data);
|
999 |
event.params.value = (data.base_price+items_sum )* qty;
|
@@ -1003,7 +1044,7 @@ if (!Array.prototype.includes) {
|
|
1003 |
}
|
1004 |
|
1005 |
// only when non Facebook for WooCommerce logic used
|
1006 |
-
if (event.params.hasOwnProperty('contents')) {
|
1007 |
event.params.contents[0].quantity = qty;
|
1008 |
}
|
1009 |
|
@@ -1278,7 +1319,7 @@ if (!Array.prototype.includes) {
|
|
1278 |
|
1279 |
if (window.pysWooProductData.hasOwnProperty(product_id)) {
|
1280 |
if (window.pysWooProductData[product_id].hasOwnProperty('ga')) {
|
1281 |
-
Utils.copyProperties(window.pysWooProductData[product_id]['ga'], event.params)
|
1282 |
this.fireEvent(event.name, event);
|
1283 |
}
|
1284 |
}
|
@@ -1294,18 +1335,54 @@ if (!Array.prototype.includes) {
|
|
1294 |
return;
|
1295 |
var event = Utils.clone(options.dynamicEvents.woo_add_to_cart_on_button_click[this.tag()]);
|
1296 |
|
1297 |
-
if (product_type === PRODUCT_VARIABLE) {
|
1298 |
product_id = parseInt($form.find('input[name="variation_id"]').val());
|
1299 |
}
|
1300 |
|
1301 |
if (window.pysWooProductData.hasOwnProperty(product_id)) {
|
1302 |
if (window.pysWooProductData[product_id].hasOwnProperty('ga')) {
|
1303 |
|
1304 |
-
Utils.copyProperties(window.pysWooProductData[product_id]['ga'], event.params);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1305 |
|
1306 |
// maybe customize value option
|
1307 |
-
if (options.woo.addToCartOnButtonValueEnabled &&
|
1308 |
-
|
|
|
|
|
|
|
1309 |
var data = $(".bundle_form .bundle_data").data("bundle_form_data");
|
1310 |
var items_sum = getBundlePriceOnSingleProduct(data);
|
1311 |
event.params.items[0].price = (data.base_price+items_sum )* qty;
|
@@ -1315,8 +1392,6 @@ if (!Array.prototype.includes) {
|
|
1315 |
|
1316 |
}
|
1317 |
|
1318 |
-
// update items qty param
|
1319 |
-
event.params.items[0].quantity = qty;
|
1320 |
|
1321 |
this.fireEvent(event.name, event);
|
1322 |
}
|
@@ -1334,7 +1409,7 @@ if (!Array.prototype.includes) {
|
|
1334 |
|
1335 |
if(!options.dynamicEvents.edd_add_to_cart_on_button_click.hasOwnProperty(this.tag()))
|
1336 |
return;
|
1337 |
-
var event = options.dynamicEvents.edd_add_to_cart_on_button_click[this.tag()];
|
1338 |
|
1339 |
|
1340 |
if (window.pysEddProductData.hasOwnProperty(download_id)) {
|
@@ -1348,23 +1423,20 @@ if (!Array.prototype.includes) {
|
|
1348 |
}
|
1349 |
|
1350 |
if (window.pysEddProductData[download_id].hasOwnProperty(index)) {
|
1351 |
-
if (window.pysEddProductData[download_id][index].hasOwnProperty('
|
|
|
|
|
1352 |
|
1353 |
-
event = Utils.clone(event)
|
1354 |
-
Utils.copyProperties(window.pysEddProductData[download_id][index]['google_ads']['params'], event.params);
|
1355 |
-
event['ids'] = window.pysEddProductData[download_id][index]['google_ads']['ids'];
|
1356 |
-
event['conversion_labels'] = window.pysEddProductData[download_id][index]['google_ads']['conversion_labels'];
|
1357 |
// update items qty param
|
1358 |
-
params.items[0].quantity = qty;
|
1359 |
|
1360 |
-
this.fireEvent(event.name,
|
1361 |
|
1362 |
}
|
1363 |
}
|
1364 |
|
1365 |
}
|
1366 |
|
1367 |
-
|
1368 |
},
|
1369 |
|
1370 |
onEddRemoveFromCartEvent: function (event) {
|
@@ -1386,10 +1458,6 @@ if (!Array.prototype.includes) {
|
|
1386 |
window.pys.Analytics = Analytics;
|
1387 |
window.pys.Utils = Utils;
|
1388 |
|
1389 |
-
const PRODUCT_SIMPLE = 0;
|
1390 |
-
const PRODUCT_VARIABLE = 1;
|
1391 |
-
const PRODUCT_BUNDLE = 2;
|
1392 |
-
|
1393 |
function getPixelBySlag(slug) {
|
1394 |
switch (slug) {
|
1395 |
case "facebook": return window.pys.Facebook;
|
@@ -1548,22 +1616,28 @@ if (!Array.prototype.includes) {
|
|
1548 |
|
1549 |
var $form = $button.closest('form');
|
1550 |
|
1551 |
-
var product_type = PRODUCT_SIMPLE;
|
1552 |
|
1553 |
if ($form.length === 0) {
|
1554 |
return ;
|
1555 |
} else if ($form.hasClass('variations_form')) {
|
1556 |
-
product_type = PRODUCT_VARIABLE;
|
1557 |
} else if($form.hasClass('bundle_form')) {
|
1558 |
-
product_type = PRODUCT_BUNDLE;
|
|
|
|
|
1559 |
}
|
1560 |
|
1561 |
|
1562 |
|
|
|
1563 |
var product_id;
|
1564 |
var qty;
|
1565 |
|
1566 |
-
if (product_type ===
|
|
|
|
|
|
|
1567 |
product_id = parseInt($form.find('*[name="add-to-cart"]').val());
|
1568 |
var qtyTag = $form.find('input[name="quantity"]');
|
1569 |
if(qtyTag.length <= 0) {
|
215 |
* PUBLIC API
|
216 |
*/
|
217 |
return {
|
218 |
+
PRODUCT_SIMPLE : 0,
|
219 |
+
PRODUCT_VARIABLE : 1,
|
220 |
+
PRODUCT_BUNDLE : 2,
|
221 |
+
PRODUCT_GROUPED : 3,
|
222 |
fireEventForAllPixel:function(functionName,events){
|
223 |
if (events.hasOwnProperty(Facebook.tag()))
|
224 |
Facebook[functionName](events[Facebook.tag()]);
|
973 |
if (window.pysWooProductData.hasOwnProperty(product_id)) {
|
974 |
if (window.pysWooProductData[product_id].hasOwnProperty('facebook')) {
|
975 |
event = Utils.copyProperties(event, {})
|
976 |
+
Utils.copyProperties(window.pysWooProductData[product_id]['facebook'].params, event.params)
|
977 |
this.fireEvent(event.name, event);
|
978 |
}
|
979 |
}
|
988 |
if (window.pysWooProductData.hasOwnProperty(product_id)) {
|
989 |
if (window.pysWooProductData[product_id].hasOwnProperty('facebook')) {
|
990 |
|
991 |
+
if (product_type === Utils.PRODUCT_VARIABLE && !options.facebook.wooVariableAsSimple) {
|
992 |
product_id = parseInt($form.find('input[name="variation_id"]').val());
|
993 |
}
|
994 |
+
Utils.copyProperties(window.pysWooProductData[product_id]['facebook'].params, event.params);
|
995 |
+
|
996 |
+
var groupValue = 0;
|
997 |
+
if(product_type === Utils.PRODUCT_GROUPED ) {
|
998 |
+
$form.find(".woocommerce-grouped-product-list .qty").each(function(index){
|
999 |
+
var childId = $(this).attr('name').replaceAll("quantity[","").replaceAll("]","");
|
1000 |
+
var quantity = parseInt($(this).val());
|
1001 |
+
if(isNaN(quantity)) {
|
1002 |
+
quantity = 0;
|
1003 |
+
}
|
1004 |
+
var childItem = window.pysWooProductData[product_id]['facebook'].grouped[childId];
|
1005 |
+
|
1006 |
+
if(quantity == 0) {
|
1007 |
+
event.params.content_ids.forEach(function(el,index,array) {
|
1008 |
+
if(el == childItem.content_id) {
|
1009 |
+
array.splice(index, 1);
|
1010 |
+
}
|
1011 |
+
});
|
1012 |
+
}
|
1013 |
+
|
1014 |
+
if(event.params.hasOwnProperty('contents')) {
|
1015 |
+
event.params.contents.forEach(function(el,index,array) {
|
1016 |
+
if(el.id == childItem.content_id) {
|
1017 |
+
if(quantity > 0){
|
1018 |
+
el.quantity = quantity;
|
1019 |
+
} else {
|
1020 |
+
array.splice(index, 1);
|
1021 |
+
}
|
1022 |
+
}
|
1023 |
+
});
|
1024 |
+
}
|
1025 |
+
|
1026 |
|
1027 |
+
groupValue += childItem.price * quantity;
|
1028 |
+
});
|
1029 |
+
if(groupValue == 0) return; // skip if no items selected
|
1030 |
+
}
|
1031 |
|
1032 |
// maybe customize value option
|
1033 |
if (options.woo.addToCartOnButtonValueEnabled && options.woo.addToCartOnButtonValueOption !== 'global') {
|
1034 |
|
1035 |
+
if(product_type === Utils.PRODUCT_GROUPED) {
|
1036 |
+
event.params.value = groupValue;
|
1037 |
+
} else if(product_type === Utils.PRODUCT_BUNDLE) {
|
1038 |
var data = $(".bundle_form .bundle_data").data("bundle_form_data");
|
1039 |
var items_sum = getBundlePriceOnSingleProduct(data);
|
1040 |
event.params.value = (data.base_price+items_sum )* qty;
|
1044 |
}
|
1045 |
|
1046 |
// only when non Facebook for WooCommerce logic used
|
1047 |
+
if (event.params.hasOwnProperty('contents') && product_type !== Utils.PRODUCT_GROUPED) {
|
1048 |
event.params.contents[0].quantity = qty;
|
1049 |
}
|
1050 |
|
1319 |
|
1320 |
if (window.pysWooProductData.hasOwnProperty(product_id)) {
|
1321 |
if (window.pysWooProductData[product_id].hasOwnProperty('ga')) {
|
1322 |
+
Utils.copyProperties(window.pysWooProductData[product_id]['ga'].params, event.params)
|
1323 |
this.fireEvent(event.name, event);
|
1324 |
}
|
1325 |
}
|
1335 |
return;
|
1336 |
var event = Utils.clone(options.dynamicEvents.woo_add_to_cart_on_button_click[this.tag()]);
|
1337 |
|
1338 |
+
if (product_type === Utils.PRODUCT_VARIABLE) {
|
1339 |
product_id = parseInt($form.find('input[name="variation_id"]').val());
|
1340 |
}
|
1341 |
|
1342 |
if (window.pysWooProductData.hasOwnProperty(product_id)) {
|
1343 |
if (window.pysWooProductData[product_id].hasOwnProperty('ga')) {
|
1344 |
|
1345 |
+
Utils.copyProperties(window.pysWooProductData[product_id]['ga'].params, event.params);
|
1346 |
+
if(product_type === Utils.PRODUCT_GROUPED ) {
|
1347 |
+
var groupValue = 0;
|
1348 |
+
$form.find(".woocommerce-grouped-product-list .qty").each(function(index){
|
1349 |
+
var childId = $(this).attr('name').replaceAll("quantity[","").replaceAll("]","");
|
1350 |
+
var quantity = parseInt($(this).val());
|
1351 |
+
if(isNaN(quantity)) {
|
1352 |
+
quantity = 0;
|
1353 |
+
}
|
1354 |
+
var childItem = window.pysWooProductData[product_id]['ga'].grouped[childId];
|
1355 |
+
|
1356 |
+
if(options.woo.addToCartOnButtonValueEnabled &&
|
1357 |
+
options.woo.addToCartOnButtonValueOption !== 'global') {
|
1358 |
+
|
1359 |
+
event.params.items.forEach(function(el,index,array) {
|
1360 |
+
if(el.id == childItem.content_id) {
|
1361 |
+
if(quantity > 0){
|
1362 |
+
el.quantity = quantity;
|
1363 |
+
el.price = childItem.price * quantity;
|
1364 |
+
} else {
|
1365 |
+
array.splice(index, 1);
|
1366 |
+
}
|
1367 |
+
}
|
1368 |
+
});
|
1369 |
+
|
1370 |
+
}
|
1371 |
+
groupValue += childItem.price * quantity;
|
1372 |
+
});
|
1373 |
+
|
1374 |
+
if(groupValue == 0) return; // skip if no items selected
|
1375 |
+
} else {
|
1376 |
+
// update items qty param
|
1377 |
+
event.params.items[0].quantity = qty;
|
1378 |
+
}
|
1379 |
|
1380 |
// maybe customize value option
|
1381 |
+
if (options.woo.addToCartOnButtonValueEnabled &&
|
1382 |
+
options.woo.addToCartOnButtonValueOption !== 'global' &&
|
1383 |
+
product_type !== Utils.PRODUCT_GROUPED)
|
1384 |
+
{
|
1385 |
+
if(product_type === Utils.PRODUCT_BUNDLE) {
|
1386 |
var data = $(".bundle_form .bundle_data").data("bundle_form_data");
|
1387 |
var items_sum = getBundlePriceOnSingleProduct(data);
|
1388 |
event.params.items[0].price = (data.base_price+items_sum )* qty;
|
1392 |
|
1393 |
}
|
1394 |
|
|
|
|
|
1395 |
|
1396 |
this.fireEvent(event.name, event);
|
1397 |
}
|
1409 |
|
1410 |
if(!options.dynamicEvents.edd_add_to_cart_on_button_click.hasOwnProperty(this.tag()))
|
1411 |
return;
|
1412 |
+
var event = Utils.clone(options.dynamicEvents.edd_add_to_cart_on_button_click[this.tag()]);
|
1413 |
|
1414 |
|
1415 |
if (window.pysEddProductData.hasOwnProperty(download_id)) {
|
1423 |
}
|
1424 |
|
1425 |
if (window.pysEddProductData[download_id].hasOwnProperty(index)) {
|
1426 |
+
if (window.pysEddProductData[download_id][index].hasOwnProperty('ga')) {
|
1427 |
+
|
1428 |
+
Utils.copyProperties(window.pysEddProductData[download_id][index]['ga'].params, event.params);
|
1429 |
|
|
|
|
|
|
|
|
|
1430 |
// update items qty param
|
1431 |
+
event.params.items[0].quantity = qty;
|
1432 |
|
1433 |
+
this.fireEvent(event.name,event);
|
1434 |
|
1435 |
}
|
1436 |
}
|
1437 |
|
1438 |
}
|
1439 |
|
|
|
1440 |
},
|
1441 |
|
1442 |
onEddRemoveFromCartEvent: function (event) {
|
1458 |
window.pys.Analytics = Analytics;
|
1459 |
window.pys.Utils = Utils;
|
1460 |
|
|
|
|
|
|
|
|
|
1461 |
function getPixelBySlag(slug) {
|
1462 |
switch (slug) {
|
1463 |
case "facebook": return window.pys.Facebook;
|
1616 |
|
1617 |
var $form = $button.closest('form');
|
1618 |
|
1619 |
+
var product_type = Utils.PRODUCT_SIMPLE;
|
1620 |
|
1621 |
if ($form.length === 0) {
|
1622 |
return ;
|
1623 |
} else if ($form.hasClass('variations_form')) {
|
1624 |
+
product_type = Utils.PRODUCT_VARIABLE;
|
1625 |
} else if($form.hasClass('bundle_form')) {
|
1626 |
+
product_type = Utils.PRODUCT_BUNDLE;
|
1627 |
+
} else if($form.hasClass('grouped_form')) {
|
1628 |
+
product_type = Utils.PRODUCT_GROUPED;
|
1629 |
}
|
1630 |
|
1631 |
|
1632 |
|
1633 |
+
|
1634 |
var product_id;
|
1635 |
var qty;
|
1636 |
|
1637 |
+
if (product_type === Utils.PRODUCT_GROUPED) {
|
1638 |
+
qty = 1;
|
1639 |
+
product_id = parseInt($form.find('*[name="add-to-cart"]').val());
|
1640 |
+
} else if (product_type === Utils.PRODUCT_VARIABLE) {
|
1641 |
product_id = parseInt($form.find('*[name="add-to-cart"]').val());
|
1642 |
var qtyTag = $form.find('input[name="quantity"]');
|
1643 |
if(qtyTag.length <= 0) {
|
facebook-pixel-master.php
CHANGED
@@ -4,7 +4,7 @@
|
|
4 |
* Plugin Name: PixelYourSite
|
5 |
* Plugin URI: http://www.pixelyoursite.com/
|
6 |
* Description: No codding <strong>Facebook Pixel</strong> and <strong>Google Analytics</strong> install. Track key actions with our Global Events, or configure your own events. WooCommerce and EDD fully supported, with Facebook Dynamic Ads Pixel set-up and Google Analytics Enhanced Ecommerce. Insert any custom script with our Head & Footer option. Add the <strong>Pinterest Tag</strong> with our free add-on. The PRO version adds support for the Google Ads tag plus a lot of extra stuff.
|
7 |
-
* Version: 8.0.
|
8 |
* Author: PixelYourSite
|
9 |
* Author URI: http://www.pixelyoursite.com
|
10 |
* License: GPLv3
|
4 |
* Plugin Name: PixelYourSite
|
5 |
* Plugin URI: http://www.pixelyoursite.com/
|
6 |
* Description: No codding <strong>Facebook Pixel</strong> and <strong>Google Analytics</strong> install. Track key actions with our Global Events, or configure your own events. WooCommerce and EDD fully supported, with Facebook Dynamic Ads Pixel set-up and Google Analytics Enhanced Ecommerce. Insert any custom script with our Head & Footer option. Add the <strong>Pinterest Tag</strong> with our free add-on. The PRO version adds support for the Google Ads tag plus a lot of extra stuff.
|
7 |
+
* Version: 8.0.4
|
8 |
* Author: PixelYourSite
|
9 |
* Author URI: http://www.pixelyoursite.com
|
10 |
* License: GPLv3
|
includes/class-events-manager.php
CHANGED
@@ -250,8 +250,13 @@ class EventsManager {
|
|
250 |
}
|
251 |
$eventData = $event->getData();
|
252 |
//save static event data
|
253 |
-
$
|
254 |
-
|
|
|
|
|
|
|
|
|
|
|
255 |
}
|
256 |
|
257 |
/**
|
@@ -362,16 +367,11 @@ class EventsManager {
|
|
362 |
|
363 |
public function setupWooProductData($product) {
|
364 |
|
365 |
-
if ( wooProductIsType( $product, 'variable' ) ) {
|
366 |
return; // skip variable products
|
367 |
}
|
368 |
-
|
369 |
-
|
370 |
-
if ( isWooCommerceVersionGte( '2.6' ) ) {
|
371 |
-
$product_id = $product->get_id();
|
372 |
-
} else {
|
373 |
-
$product_id = $product->post->ID;
|
374 |
-
}
|
375 |
|
376 |
$params = array();
|
377 |
|
@@ -384,9 +384,13 @@ class EventsManager {
|
|
384 |
continue; // event is disabled or not supported for the pixel
|
385 |
}
|
386 |
|
387 |
-
|
|
|
|
|
|
|
388 |
|
389 |
-
|
|
|
390 |
|
391 |
if ( empty( $params ) ) {
|
392 |
return;
|
@@ -452,7 +456,11 @@ class EventsManager {
|
|
452 |
continue; // event is disabled or not supported for the pixel
|
453 |
}
|
454 |
|
455 |
-
|
|
|
|
|
|
|
|
|
456 |
|
457 |
}
|
458 |
}
|
@@ -506,9 +514,11 @@ class EventsManager {
|
|
506 |
if ( false === $eventData ) {
|
507 |
continue; // event is disabled or not supported for the pixel
|
508 |
}
|
|
|
|
|
|
|
509 |
|
510 |
-
$params[ $download_id ][ $pixel->getSlug() ] =
|
511 |
-
|
512 |
}
|
513 |
}
|
514 |
|
250 |
}
|
251 |
$eventData = $event->getData();
|
252 |
//save static event data
|
253 |
+
if($event->getId() == "custom_event") {
|
254 |
+
$eventId = $event->args->getPostId();
|
255 |
+
} else {
|
256 |
+
$eventId = $event->getId();
|
257 |
+
}
|
258 |
+
$this->triggerEvents[ $eventId ][ $pixel->getSlug() ] = $eventData;
|
259 |
+
$this->triggerEventTypes[ $eventData['trigger_type'] ][ $eventId ][] = $eventData['trigger_value'];
|
260 |
}
|
261 |
|
262 |
/**
|
367 |
|
368 |
public function setupWooProductData($product) {
|
369 |
|
370 |
+
if ( wooProductIsType( $product, 'variable' ) || wooProductIsType( $product, 'grouped' ) ) {
|
371 |
return; // skip variable products
|
372 |
}
|
373 |
+
|
374 |
+
$product_id = $product->get_id();
|
|
|
|
|
|
|
|
|
|
|
375 |
|
376 |
$params = array();
|
377 |
|
384 |
continue; // event is disabled or not supported for the pixel
|
385 |
}
|
386 |
|
387 |
+
if(isset($eventData['params']))
|
388 |
+
$eventData['params'] = sanitizeParams($eventData['params']);
|
389 |
+
else $eventData['params'] = sanitizeParams($eventData['data']);
|
390 |
+
$params[$pixel->getSlug()] = $eventData;
|
391 |
|
392 |
+
|
393 |
+
}
|
394 |
|
395 |
if ( empty( $params ) ) {
|
396 |
return;
|
456 |
continue; // event is disabled or not supported for the pixel
|
457 |
}
|
458 |
|
459 |
+
if(isset($eventData['params']))
|
460 |
+
$eventData['params'] = sanitizeParams($eventData['params']);
|
461 |
+
else $eventData['params'] = sanitizeParams($eventData['data']);
|
462 |
+
|
463 |
+
$params[ $product_id ][ $pixel->getSlug() ] = $eventData;
|
464 |
|
465 |
}
|
466 |
}
|
514 |
if ( false === $eventData ) {
|
515 |
continue; // event is disabled or not supported for the pixel
|
516 |
}
|
517 |
+
if(isset($eventData['params']))
|
518 |
+
$eventData['params'] = sanitizeParams($eventData['params']);
|
519 |
+
else $eventData['params'] = sanitizeParams($eventData['data']);
|
520 |
|
521 |
+
$params[ $download_id ][ $pixel->getSlug() ] = $eventData;
|
|
|
522 |
}
|
523 |
}
|
524 |
|
modules/facebook/facebook.php
CHANGED
@@ -425,6 +425,8 @@ class Facebook extends Settings implements Pixel {
|
|
425 |
);
|
426 |
|
427 |
foreach ( $event['params'] as $param => $value ) {
|
|
|
|
|
428 |
@$args[ 'cd[' . $param . ']' ] = urlencode( $value );
|
429 |
}
|
430 |
|
@@ -670,10 +672,22 @@ class Facebook extends Settings implements Pixel {
|
|
670 |
}
|
671 |
|
672 |
$params = Helpers\getWooSingleAddToCartParams( $product_id, 1 );
|
673 |
-
|
674 |
-
|
675 |
-
|
676 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
677 |
|
678 |
}
|
679 |
|
@@ -1000,7 +1014,7 @@ class Facebook extends Settings implements Pixel {
|
|
1000 |
);
|
1001 |
|
1002 |
return array(
|
1003 |
-
'
|
1004 |
);
|
1005 |
|
1006 |
}
|
425 |
);
|
426 |
|
427 |
foreach ( $event['params'] as $param => $value ) {
|
428 |
+
if(is_array($value))
|
429 |
+
$value = json_encode($value);
|
430 |
@$args[ 'cd[' . $param . ']' ] = urlencode( $value );
|
431 |
}
|
432 |
|
672 |
}
|
673 |
|
674 |
$params = Helpers\getWooSingleAddToCartParams( $product_id, 1 );
|
675 |
+
$data = array(
|
676 |
+
'params' => $params,
|
677 |
+
);
|
678 |
+
$product = wc_get_product($product_id);
|
679 |
+
if($product->get_type() == 'grouped') {
|
680 |
+
$grouped = array();
|
681 |
+
foreach ($product->get_children() as $childId) {
|
682 |
+
$conId = Helpers\getFacebookWooProductContentId( $childId );
|
683 |
+
$grouped[$childId] = array(
|
684 |
+
'content_id' => (string) reset($conId),
|
685 |
+
'price' => getWooProductPriceToDisplay( $childId )
|
686 |
+
);
|
687 |
+
}
|
688 |
+
$data['grouped'] = $grouped;
|
689 |
+
}
|
690 |
+
return $data;
|
691 |
|
692 |
}
|
693 |
|
1014 |
);
|
1015 |
|
1016 |
return array(
|
1017 |
+
'params' => $params,
|
1018 |
);
|
1019 |
|
1020 |
}
|
modules/facebook/function-helpers.php
CHANGED
@@ -276,18 +276,28 @@ function getWooCustomAudiencesOptimizationParams( $post_id ) {
|
|
276 |
|
277 |
}
|
278 |
|
279 |
-
function getWooSingleAddToCartParams( $
|
280 |
|
281 |
$params = array();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
282 |
|
283 |
-
$content_id = getFacebookWooProductContentId( $product_id );
|
284 |
|
285 |
-
$params['content_type'] = 'product';
|
286 |
-
$params['content_ids'] = ( $content_id );
|
287 |
|
288 |
// content_name, category_name, tags
|
289 |
-
$params['tags'] = implode( ', ', PixelYourSite\getObjectTerms( 'product_tag', $
|
290 |
-
$params = array_merge( $params, getWooCustomAudiencesOptimizationParams( $
|
291 |
|
292 |
// currency, value
|
293 |
if ( PixelYourSite\PYS()->getOption( 'woo_add_to_cart_value_enabled' ) ) {
|
@@ -295,25 +305,29 @@ function getWooSingleAddToCartParams( $product_id, $qty = 1 ) {
|
|
295 |
$value_option = PixelYourSite\PYS()->getOption( 'woo_add_to_cart_value_option' );
|
296 |
$global_value = PixelYourSite\PYS()->getOption( 'woo_add_to_cart_value_global', 0 );
|
297 |
|
298 |
-
$params['value'] = PixelYourSite\getWooEventValue( $value_option, $global_value,100, $
|
299 |
$params['currency'] = get_woocommerce_currency();
|
300 |
|
301 |
}
|
302 |
|
303 |
-
|
304 |
-
|
305 |
-
|
306 |
-
|
307 |
-
|
308 |
-
|
309 |
-
|
310 |
-
|
311 |
-
|
312 |
-
|
313 |
-
|
314 |
-
|
315 |
-
|
316 |
-
|
|
|
|
|
|
|
|
|
317 |
|
318 |
return $params;
|
319 |
|
276 |
|
277 |
}
|
278 |
|
279 |
+
function getWooSingleAddToCartParams( $_product_id, $qty = 1 ) {
|
280 |
|
281 |
$params = array();
|
282 |
+
$product = wc_get_product($_product_id);
|
283 |
+
if(!$product) return array();
|
284 |
+
$product_ids = array();
|
285 |
+
|
286 |
+
if($product->get_type() == "grouped") {
|
287 |
+
$product_ids = $product->get_children();
|
288 |
+
} else {
|
289 |
+
$product_ids[] = $_product_id;
|
290 |
+
}
|
291 |
+
$params['content_type'] = 'product';
|
292 |
+
$params['content_ids'] = array();
|
293 |
+
$params['contents'] = array();
|
294 |
+
|
295 |
|
|
|
296 |
|
|
|
|
|
297 |
|
298 |
// content_name, category_name, tags
|
299 |
+
$params['tags'] = implode( ', ', PixelYourSite\getObjectTerms( 'product_tag', $_product_id ) );
|
300 |
+
$params = array_merge( $params, getWooCustomAudiencesOptimizationParams( $_product_id ) );
|
301 |
|
302 |
// currency, value
|
303 |
if ( PixelYourSite\PYS()->getOption( 'woo_add_to_cart_value_enabled' ) ) {
|
305 |
$value_option = PixelYourSite\PYS()->getOption( 'woo_add_to_cart_value_option' );
|
306 |
$global_value = PixelYourSite\PYS()->getOption( 'woo_add_to_cart_value_global', 0 );
|
307 |
|
308 |
+
$params['value'] = PixelYourSite\getWooEventValue( $value_option, $global_value,100, $_product_id,$qty );
|
309 |
$params['currency'] = get_woocommerce_currency();
|
310 |
|
311 |
}
|
312 |
|
313 |
+
foreach ($product_ids as $product_id) {
|
314 |
+
$product = wc_get_product($product_id);
|
315 |
+
if($product->get_type() == "variable") {
|
316 |
+
continue;
|
317 |
+
}
|
318 |
+
$content_id = getFacebookWooProductContentId( $product_id );
|
319 |
+
$params['content_ids'] = array_merge($params['content_ids'],$content_id);
|
320 |
+
// contents
|
321 |
+
if ( isDefaultWooContentIdLogic() ) {
|
322 |
+
|
323 |
+
// Facebook for WooCommerce plugin does not support new Dynamic Ads parameters
|
324 |
+
$params['contents'][] = array(
|
325 |
+
'id' => (string) reset( $content_id ),
|
326 |
+
'quantity' => 1,
|
327 |
+
//'item_price' => PixelYourSite\getWooProductPriceToDisplay( $product_id ),// remove because price need send only with currency
|
328 |
+
);
|
329 |
+
}
|
330 |
+
}
|
331 |
|
332 |
return $params;
|
333 |
|
modules/google_analytics/ga.php
CHANGED
@@ -562,38 +562,66 @@ class GA extends Settings implements Pixel {
|
|
562 |
if ( ! $this->getOption( 'woo_add_to_cart_enabled' ) || ! PYS()->getOption( 'woo_add_to_cart_on_button_click' ) ) {
|
563 |
return false;
|
564 |
}
|
565 |
-
$
|
566 |
-
$product = wc_get_product( $product_id );
|
567 |
if(!$product) return false;
|
568 |
-
$price = getWooProductPriceToDisplay( $product_id, 1 );
|
569 |
-
$name = $product->get_title();
|
570 |
|
571 |
-
|
572 |
-
|
573 |
-
|
|
|
574 |
} else {
|
575 |
-
$
|
576 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
577 |
}
|
578 |
|
|
|
579 |
$params = array(
|
580 |
'event_category' => 'ecommerce',
|
581 |
-
'items' =>
|
582 |
-
array(
|
583 |
-
'id' => $content_id,
|
584 |
-
'name' => $name,
|
585 |
-
'category' => $categories,
|
586 |
-
'quantity' => 1,
|
587 |
-
'price' => $price,
|
588 |
-
'variant' => $variation_name,
|
589 |
-
),
|
590 |
-
),
|
591 |
'non_interaction' => $this->getOption( 'woo_add_to_cart_non_interactive' ),
|
592 |
);
|
593 |
|
594 |
-
|
595 |
-
|
596 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
597 |
|
598 |
}
|
599 |
|
@@ -887,7 +915,7 @@ class GA extends Settings implements Pixel {
|
|
887 |
);
|
888 |
|
889 |
return array(
|
890 |
-
'
|
891 |
);
|
892 |
|
893 |
}
|
562 |
if ( ! $this->getOption( 'woo_add_to_cart_enabled' ) || ! PYS()->getOption( 'woo_add_to_cart_on_button_click' ) ) {
|
563 |
return false;
|
564 |
}
|
565 |
+
$product = wc_get_product( $product_id );
|
|
|
566 |
if(!$product) return false;
|
|
|
|
|
567 |
|
568 |
+
$product_ids = array();
|
569 |
+
$items = array();
|
570 |
+
if($product->get_type() == "grouped") {
|
571 |
+
$product_ids = $product->get_children();
|
572 |
} else {
|
573 |
+
$product_ids[] = $product_id;
|
574 |
+
}
|
575 |
+
|
576 |
+
foreach ($product_ids as $child_id) {
|
577 |
+
$childProduct = wc_get_product($child_id);
|
578 |
+
if($childProduct->get_type() == "variable") {
|
579 |
+
continue;
|
580 |
+
}
|
581 |
+
$content_id = GA\Helpers\getWooProductContentId($child_id);
|
582 |
+
$price = getWooProductPriceToDisplay( $child_id, 1 );
|
583 |
+
$name = $childProduct->get_title();
|
584 |
+
|
585 |
+
if ( $childProduct->get_type() == 'variation' ) {
|
586 |
+
$variation_name = implode("/", $childProduct->get_variation_attributes());
|
587 |
+
$categories = implode( '/', getObjectTerms( 'product_cat', $childProduct->get_parent_id() ) );
|
588 |
+
} else {
|
589 |
+
$categories = implode( '/', getObjectTerms( 'product_cat', $child_id ) );
|
590 |
+
$variation_name = null;
|
591 |
+
}
|
592 |
+
$items[] = array(
|
593 |
+
'id' => $content_id,
|
594 |
+
'name' => $name,
|
595 |
+
'category' => $categories,
|
596 |
+
'quantity' => 1,
|
597 |
+
'price' => $price,
|
598 |
+
'variant' => $variation_name,
|
599 |
+
);
|
600 |
}
|
601 |
|
602 |
+
|
603 |
$params = array(
|
604 |
'event_category' => 'ecommerce',
|
605 |
+
'items' => $items,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
606 |
'non_interaction' => $this->getOption( 'woo_add_to_cart_non_interactive' ),
|
607 |
);
|
608 |
|
609 |
+
$data = array(
|
610 |
+
'params' => $params,
|
611 |
+
);
|
612 |
+
|
613 |
+
if($product->get_type() == 'grouped') {
|
614 |
+
$grouped = array();
|
615 |
+
foreach ($product->get_children() as $childId) {
|
616 |
+
$grouped[$childId] = array(
|
617 |
+
'content_id' => GA\Helpers\getWooProductContentId( $childId ),
|
618 |
+
'price' => getWooProductPriceToDisplay( $childId )
|
619 |
+
);
|
620 |
+
}
|
621 |
+
$data['grouped'] = $grouped;
|
622 |
+
}
|
623 |
+
|
624 |
+
return $data;
|
625 |
|
626 |
}
|
627 |
|
915 |
);
|
916 |
|
917 |
return array(
|
918 |
+
'params' => $params,
|
919 |
);
|
920 |
|
921 |
}
|
pixelyoursite.php
CHANGED
@@ -4,7 +4,7 @@ if ( ! defined( 'ABSPATH' ) ) {
|
|
4 |
exit; // Exit if accessed directly.
|
5 |
}
|
6 |
|
7 |
-
define( 'PYS_FREE_VERSION', '8.0.
|
8 |
define( 'PYS_FREE_PINTEREST_MIN_VERSION', '3.0.0' );
|
9 |
define( 'PYS_FREE_BING_MIN_VERSION', '2.0.0' );
|
10 |
define( 'PYS_FREE_PATH', untrailingslashit( plugin_dir_path( __FILE__ ) ) );
|
4 |
exit; // Exit if accessed directly.
|
5 |
}
|
6 |
|
7 |
+
define( 'PYS_FREE_VERSION', '8.0.4' );
|
8 |
define( 'PYS_FREE_PINTEREST_MIN_VERSION', '3.0.0' );
|
9 |
define( 'PYS_FREE_BING_MIN_VERSION', '2.0.0' );
|
10 |
define( 'PYS_FREE_PATH', untrailingslashit( plugin_dir_path( __FILE__ ) ) );
|
readme.txt
CHANGED
@@ -4,7 +4,7 @@ Tags: Facebook Pixel, New Facebook Pixel, Facebook Conversion Pixel, Facebook Pi
|
|
4 |
Requires at least: 3.0.1
|
5 |
Requires PHP: 5.4
|
6 |
Tested up to: 5.6
|
7 |
-
Stable tag: 8.0.
|
8 |
License: GPLv3
|
9 |
License URI: http://www.gnu.org/licenses/gpl-3.0.html
|
10 |
|
@@ -396,6 +396,16 @@ NO, absolutely not! We don't track any type of data about your website. We simpl
|
|
396 |
== Changelog ==
|
397 |
|
398 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
399 |
= PixelYourSite 8.0.3 =
|
400 |
|
401 |
* FIX: some encoding problems with parameter values.
|
4 |
Requires at least: 3.0.1
|
5 |
Requires PHP: 5.4
|
6 |
Tested up to: 5.6
|
7 |
+
Stable tag: 8.0.4
|
8 |
License: GPLv3
|
9 |
License URI: http://www.gnu.org/licenses/gpl-3.0.html
|
10 |
|
396 |
== Changelog ==
|
397 |
|
398 |
|
399 |
+
= PixelYourSite 8.0.4 =
|
400 |
+
|
401 |
+
* FIX: Warning: Invalid argument supplied for foreach() .... wp-content/plugins/pixelyoursite/includes/functions-common.php on line 688
|
402 |
+
|
403 |
+
* FIX: WooCommerce group products possible value issue.
|
404 |
+
|
405 |
+
* FIX: Possible problem with Easy Digital Downloads add to cart.
|
406 |
+
|
407 |
+
|
408 |
+
|
409 |
= PixelYourSite 8.0.3 =
|
410 |
|
411 |
* FIX: some encoding problems with parameter values.
|