Posts tagged with gtag.js

So I am trying to send ga ecommerce events such as "add_to_cart" or "begin_checkout". Now, in the event objects, I am confused as to what price to mention in the items array of the event object. Do I mention the discounted price or the full price?

Allow me to elaborate with examples.

gtag("event", "purchase", {     transaction_id: "T_12345",     coupon: "socksSale",     value: 12.00, // value = quantity x sale price     currency: "USD", // The currency of the value, discount, and price     items: [      {       item_id: "SKU_12345",       item_name: "Socks",       discount: 2.00, // The discount per item       price: 4.00, // The sale price is the per item list price (6.00) minus discount (2.00)       quantity: 3 // The number of items sold     },     ] }); 

This example is taken directly from here: https://developers.google.com/analytics/devguides/collection/ga4/apply-discount?client_type=gtag

Now, in the above example, Google states that the price of the items must be the discounted price:

The sale price is the per item list price (6.00) minus discount (2.00)

Now, consider another example. (Again from Google)

gtag("event", "add_to_cart", {   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     }     ] }); 

This example is taken directly from here: https://developers.google.com/analytics/devguides/collection/ga4/reference/events?client_type=gtag#add_to_cart

Here, the item price is clearly not the discounted price as the event value is this price minus the item discount e.g. The full price.

The above examples show a clear contradiction in the guidelines.

I was able to find one relevant question on Stack Overflow here: What Discount property means in Google Analytics 4? . The only answer here states that item prices should be the full prices.

Now, I understand that one can send either of the 2 types of prices as they are the ones who have to interpret the reports afterwards. However, I am sending the data to Google Ads from Google Analytics as well. And, I do not want to report inaccurate data. So, what is the more standard/accepted method of reporting item prices?

The client has requested the implementation of an event snippet on their website. This snippet involves adding a code snippet that sends hashed customer data for matching. Additionally, they have asked to include the parameter "{'allow_enhanced_conversions': true}" to the config line of the global site tag, which should trigger across all pages.

After implementing these changes, the resulting code looks as follows:

<head> <!-- Google tag (gtag.js) --> <script type="text/plain"  async src="https://www.googletagmanager.com/gtag/js?id=AW-12345"></script> <script type="text/plain"">     window.dataLayer = window.dataLayer || [];     function gtag(){dataLayer.push(arguments);}     gtag('js', new Date());     $(document).ready(function() {     var userEmail = $("#email").val();      gtag('set', 'user_data', {     "email": userEmail,       });     });     gtag('config', 'AW-12345', {'allow_enhanced_conversions': true});     gtag('config', 'AW-12346', {'allow_enhanced_conversions': true}); </script> 

However, the client has reported that the implementation has failed. Additionally, they have mentioned the absence of the ****"em" parameter in the Network Tab. I would appreciate assistance in resolving this issue.

I have a website hosted in AWS with a NodeJS backend.

I have Google Ads conversion events being sent from the frontend using gtag.js, but I noticed missing events and a lot of duplication (even if I use transaction IDs with my events)

I had similar issues with Facebook Pixel and was able to resolve the problem by sending simple vanilla http calls from my backend server.

Is it possible to do the same with Google Ads? I have not been able to find any documentation for server side APIs for Javascript. This documentation here seems promising, but no Javascript SDK exists. That's is why I would like to know what vanilla http calls to make.

I have seen documentation about GTM server side, but it seems I need to host a GTM container (server?) which I would prefer not to have to. Unless I misunderstood what hosting a GTM container means in the context of a AWS cloud solution.

How do I report conversion from gtag on server side back to google ads?

My current setup is that I report events from gtag back to google analytics 4 using unique userId (generated in my database and it's unique for each user)

    let data = {         client_id: this.getDeviceId(),         user_id: this.userId,         events: [{             name: eventName,             params: props,         }]     }     ... then send it as payload to the tracking url to the ga4 tracking url:     https://www.google-analytics.com/mp/collect?measurement_id=...&api_secret=... 

Now I launched google ads and want to report purchase and renewals as conversion.

So I imported my target event from GA4 to google ads as an offline event.

But to my understanding, in order to properly link the user back to google ads, I also need to pass gclid in gtag when I report the event/conversion, but how to do that?

Should I just add gclid as property in data? Is it documented anywhere?

I was using the below doc link in order to setup gtag tracking on the server: https://developers.google.com/analytics/devguides/collection/protocol/ga4/user-properties?client_type=gtag

I've been trying to create conversions on Google Ads after implementing small fixes to my site on Netlify. The fixes include changing button colors, adding a new button, etc. So there was no change on the GTM script. However, conversion steps were changed after a successful build on Netlify. I tried to go back to the 3-step-conversion-creation which is the way I used before the fix, I also tried to add a GTAG script to do that. I couldn't find an answer to why it has changed steps on conversion creation, because it doesn't allow me to create conversion via Google Tag Manager. I managed to go back to 3-steps-method before, I had created a new Google Ads account, but I can't use that method this time. Why it has changed? Is it about react or netlify or something else? You can view the screenshots and index.html below:

Before fix:

After fix (Website already has GTAG and GTM):

index.html:

<!DOCTYPE html> <html lang="en"> <head>   <!-- Global site tag (gtag.js) -->   <script async src="https://www.googletagmanager.com/gtag/js?id=AW-XXXXXXXXXXX"></script>   <script>window.dataLayer = window.dataLayer || [];     function gtag() { dataLayer.push(arguments); }     gtag('js', new Date());     gtag('config', 'AW-XXXXXXXXXXX');</script>   <!-- Google Tag Manager -->   <script>(function (w, d, s, l, i) {       w[l] = w[l] || []; w[l].push({         'gtm.start':           new Date().getTime(), event: 'gtm.js'       }); var f = d.getElementsByTagName(s)[0],         j = d.createElement(s), dl = l != 'dataLayer' ? '&l=' + l : ''; j.async = true; j.src =           'https://www.googletagmanager.com/gtm.js?id=' + i + dl; f.parentNode.insertBefore(j, f);     })(window, document, 'script', 'dataLayer', 'GTM-XXXXXXX');</script>   <!-- End Google Tag Manager -->   <title>Website</title>   <!-- Meta Pixel Code -->   <!-- End Meta Pixel Code --> </head> <body>   <div id="root"></div> </body> <!-- Google Tag Manager (noscript) --> <noscript><iframe src="https://www.googletagmanager.com/ns.html?id=GTM-XXXXXXX" height="0" width="0"     style="display:none;visibility:hidden"></iframe></noscript> <!-- End Google Tag Manager (noscript) --> </html>

Possible solutions to go back to 3-steps-conversion:

  • Delete BULK_ from the URL and press enter, it will direct there
  • Create a new Google Ads account but it is inconvenient and doesn't makes sense if you have balance, outsource data, etc. in that Google Ads account

Still, I have no idea why it has changed in that fix. It didn't happen on previous updates. I couldn't find any information about this. So I thought it might be related to the code. Thanks in advance.