Skip to content

Commit

Permalink
Fix: do not track internal product data (internal_id, productlink)
Browse files Browse the repository at this point in the history
  • Loading branch information
duracelltomi committed Jan 11, 2024
1 parent e316b4d commit 5e0ab13
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion js/gtm4wp-ecommerce-generic.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ function gtm4wp_push_ecommerce( event_name, items, extra_params, event_callback=
window[ gtm4wp_datalayer_name ].push(dl_obj);
}

function gtm4wp_read_json_from_node( el, dataset_item_id ) {
function gtm4wp_read_json_from_node( el, dataset_item_id, exclude_keys=['productlink', 'internal_id'] ) {
if ( el && el.dataset && el.dataset[ dataset_item_id ] ) {
try {
const parsed_json = JSON.parse( el.dataset[ dataset_item_id ] );
Expand All @@ -46,6 +46,12 @@ function gtm4wp_read_json_from_node( el, dataset_item_id ) {
parsed_json.price = gtm4wp_make_sure_is_float( parsed_json.price );
}

if ( exclude_keys && exclude_keys.length > 0 ) {
for ( let i = 0; i < exclude_keys.length; i++ ) {
delete parsed_json[ exclude_keys[i] ];
}
}

return parsed_json;
}
} catch(e) {
Expand Down

0 comments on commit 5e0ab13

Please sign in to comment.