Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

mariam528's avatar

Uncaught ReferenceError: gtag is not defined

hello i am doing google analytics eCommerce tracking in laravel . the code was working fine a few days ago. yesterday i changed my domain and changed all the necessary information but now it is showing error i have written in title. i am using default code for purchase event in controller

gtag("event", "purchase", {
  affiliation: "Google online store",
  coupon: "SUMMER_DISCOUNT",
  currency: "USD",
  shipping: 5.55,
  tax: 3.33,
  transaction_id: "T_1",
  value: 28.86,
  items: [
    {
      id: "P12345",
      name: "Android Warhol T-Shirt",
      coupon: "P12345_coupon",
      list_name: "Search Results",
      brand: "Google",
      category: "Apparel/T-Shirts",
      variant: "Black",
      list_position: 3,
      quantity: 1,
      price: 9.99
    },
    {
      id: "P12346",
      name: "Flame challenge TShirt",
      coupon: "P12346_coupon",
      list_name: "Search Results",
      brand: "MyBrand",
      category: "Apparel/T-Shirts",
      variant: "Red",
      list_position: 5,
      quantity: 1,
      price: 9.99
    }
  ]
});

and already have analytics tracking code in the head section. can anybody help me with this problem

0 likes
0 replies

Please or to participate in this conversation.