Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save wp-seopress/c77039abfd5a1e4302843708d4f9c81f to your computer and use it in GitHub Desktop.
Save wp-seopress/c77039abfd5a1e4302843708d4f9c81f to your computer and use it in GitHub Desktop.
Filter Google Analytics Ecommerce view details item event
add_filter('seopress_gtag_ec_single_view_details_ev', 'sp_gtag_ec_single_view_details_ev');
function sp_gtag_ec_single_view_details_ev($js) {
$js = 'gtag("event", "view_item", {
currency: "USD",
value: 7.77,
items: [
{
item_id: "SKU_12345",
item_name: "Stan and Friends Tee",
affiliation: "Google Merchandise Store",
coupon: "SUMMER_FUN",
discount: 2.22,
index: 0,
item_brand: "Google",
item_category: "Apparel",
item_category2: "Adult",
item_category3: "Shirts",
item_category4: "Crew",
item_category5: "Short sleeve",
item_list_id: "related_products",
item_list_name: "Related Products",
item_variant: "green",
location_id: "ChIJIQBpAG2ahYAR_6128GcTUEo",
price: 9.99,
quantity: 1
}
]
});
';
return $js;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment