Announcement

Collapse
No announcement yet.

Implementing Ecommerce purchases in GA4

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    Implementing Ecommerce purchases in GA4

    Has anyone successfully implemented the new Google Analytics GA4 on their Miva site?

    I have the general code installed in my header and am starting to gather page view data in the reports, but I don't yet have the ecommerce sales data flowing in.

    I'm wondering if someone has successfully implemented GA4 for Miva and is capturing sales data with the appropriate code on the INVC screen. If you would be willing to share your INVC page code to record sales, I (and many others I assume...) would be very grateful.
    Todd Gibson
    Oliver + S | Sewing Patterns for Kids and the Whole Family

    #2
    We have and I'm having someone post some instructions for you shortly.
    Thanks,

    Rick Wilson
    CEO
    Miva, Inc.
    [email protected]
    https://www.miva.com

    Comment


      #3
      Hey Todd -

      Here is some sample conversion tracking code for INVC for GA4. It would be recommended you set this up as a JavaScript Resource in the Miva admin and assign it to the INVC page (otherwise this needs to be wrapped in script tags if you want to include it in the page itself)

      https://docs.miva.com/code-samples/g...rsion-tracking

      Some things to keep in mind:
      - This is only the purchase event, but is the main event to track ecommerce purchasers. There are additional events such as adding/removing items from the basket or starting checkout that are not covered here. We plan on supporting this as part of broader support for GA4 in the core software in a future release. (Although you can add them manually now if needed)

      - This code has a hard code currency of USD. You adjust this as needed
      - The item identifier is the SKU field (or variant SKU if the product is an inventory variant). if the SKU is empty it will fall back to the product code
      - The first category the item was assigned to is pass as the main "item_category" identifier
      - If the item has attributes, its options are passed in the item_variant tag



      Brennan Heyde
      VP Product
      Miva, Inc.
      [email protected]
      https://www.miva.com

      Comment


        #4
        Thanks so much Brennan. Purchase data is now flowing into the new GA4 property. I'll want to add other events over time to understand the sales funnel, but for now we've got a start.
        Todd Gibson
        Oliver + S | Sewing Patterns for Kids and the Whole Family

        Comment


          #5
          Brennan I just put through a complimentary order, and I checked the script code returned on the INVC page for the order. There are a couple things I noticed that don't seem correct.

          First, all the products in the order are assigned to multiple categories, but the result did not include any category information. (Related, looking at the template code, I was wondering if the default value for category here should be the Canonical Category Code applied to the product, if there is one, instead of the first category in the list.)

          Second, the discount listed on the product is the cumulative value of the discount for the order when that product is added--not the discount on that product itself. I assume the discount should reflect the item discount, not the cumulative order discount.

          Here's the code that was generated on the INVC page for this order. The page template code is applied exactly as specified in your example.

          Code:
          gtag("event", "purchase", {
          transaction_id: "133783",
          affiliation: "Shop \u007C Oliver + S",
          value: 0,
          tax: 0,
          shipping: 0,
          currency: "USD",
          items: [
          {
          item_id: "OLV-LC048TC",
          item_name: "tribeca knit cami sewing pattern",
          affiliation: "Shop \u007C Oliver + S",
          currency: "USD",
          discount: 18.95,
          price: 0,
          quantity: 1
          }
          ,
          {
          item_id: "OLV-LC047ED",
          item_name: "enmore halter dress + top sewing pattern",
          affiliation: "Shop \u007C Oliver + S",
          currency: "USD",
          discount: 37.9,
          price: 0,
          quantity: 1
          }
          ,
          {
          item_id: "OLV-LC046LS",
          item_name: "lisboa walking shorts sewing pattern",
          affiliation: "Shop \u007C Oliver + S",
          currency: "USD",
          discount: 56.85,
          price: 0,
          quantity: 1
          }
          ,
          {
          item_id: "OLV-LC045MC",
          item_name: "melville cardigan + vest sewing pattern",
          affiliation: "Shop \u007C Oliver + S",
          currency: "USD",
          discount: 73.8,
          price: 0,
          quantity: 1
          }
          ,
          {
          item_id: "OLV-LC044GB",
          item_name: "geneva v-neck blouse sewing pattern",
          affiliation: "Shop \u007C Oliver + S",
          currency: "USD",
          discount: 92.75,
          price: 0,
          quantity: 1
          }
          ,
          {
          item_id: "OLV-LC043FD",
          item_name: "fira dress + top sewing pattern",
          affiliation: "Shop \u007C Oliver + S",
          currency: "USD",
          discount: 111.7,
          price: 0,
          quantity: 1
          }
          ]
          });
          Todd Gibson
          Oliver + S | Sewing Patterns for Kids and the Whole Family

          Comment


            #6
            Originally posted by oliverands View Post
            I just put through a complimentary order, and I checked the script code returned on the INVC page for the order. There are a couple things I noticed that don't seem correct.

            First, all the products in the order are assigned to multiple categories, but the result did not include any category information. (Related, looking at the template code, I was wondering if the default value for category here should be the Canonical Category Code applied to the product, if there is one, instead of the first category in the list.)

            Second, the discount listed on the product is the cumulative value of the discount for the order when that product is added--not the discount on that product itself. I assume the discount should reflect the item discount, not the cumulative order discount.
            I was able to correct the code in the snippet to fix the issues that you noted. The code will now check if the item has a canonical category assigned as default then fallback to the first category assigned to the product. Also, the variable for the discount (and all updated item variables for that matter) is now assigned to the item array so that the value will be assigned to the item member.

            The code on the page that Brennan noted in the previous post has been updated if you want to refer back to that for the updated version.

            Last edited by Nick; 07-01-22, 10:41 AM.
            Nicholas Adkins
            Technical Training Specialist / Miva, Inc.
            [email protected]
            https://www.miva.com/mivalearn

            Comment


              #7
              Thanks Nick! Will update and try it out later.
              Todd Gibson
              Oliver + S | Sewing Patterns for Kids and the Whole Family

              Comment


                #8
                Originally posted by Brennan View Post
                We plan on supporting this as part of broader support for GA4 in the core software in a future release.
                Any estimates on when in the future this might be?

                -- Mike

                Comment


                  #9
                  The official end of life for Universal Analytics is July 1, 2023. Historical data from Universal does not transfer over to GA4 so the earlier the better for this reason. We're targeting Q1, 2023 for a release. It's possible it could be earlier, but it unlikely to be later than that because of the hard deadline.
                  Brennan Heyde
                  VP Product
                  Miva, Inc.
                  [email protected]
                  https://www.miva.com

                  Comment

                  Working...
                  X