Created
September 14, 2023 14:23
-
-
Save wp-seopress/c77039abfd5a1e4302843708d4f9c81f to your computer and use it in GitHub Desktop.
Filter Google Analytics Ecommerce view details item event
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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