skip to Main Content

I am using Google Ads to track purchase conversions on my Ecommerce website. When a user clicks on my Google Ad for a product and then makes the purchase and lands on the thank you page, the conversion event is triggered and sends google the data so that it knows that an order has been placed and it can track the conversion.

My problem is that EACH time that same thank-you page is loaded with that users order id token, it fires that script and Google tracks that as another conversion. This should only be happening once, this should only happen the first time the page is accessed with that order token.

Take this url below for example. A user saw my Google Ad and then clicked on it and purchased and then he landed on the thank you page. At this point it was tracked as a conversion.
https ://mywebsite.com/purchase/thank-you/order/1001632bfd1c-2x5a-701t-1xs90a0a4444

Sometime later the same day or 20 days later, the user opens up the browser on his phone and that page reloads, or the user wants to check his browsing history and clicks on this url. As soon as he lands on it, the script will fire once again and count that as a conversion for the ad he originally clicked on.

Is there a way that I can make it so that the script only fires the first time a url loads?
Merchants who are using Shopify simply wrap the conversion event script with
{% If First_time_accessed %} in Liquid which is Shopify’s language. This makes it so that even if the user reloads that same url, the script won’t fire again to track that page visit as another conversion.

How do I do this type of logic if I am developing my site in ASP.net using C# MVC ?
Is there some javascript I can wrap my event snippet with to make it work like Shopify does it?
I have searched for this but keep only finding info on how to do it on Shopify.
Note…I am not using Tag Manager, I want to just leave the event snippet on my page without having to set up anything in tag manager.

Here is my script currently:

<!-- Global site tag (gtag.js) - Google Analytics -->  

<script async src="https://www.googletagmanager.com/gtag/js?id=G-M3WT222222"></script>
<script>
    window.dataLayer = window.dataLayer || [];
    function gtag() { dataLayer.push(arguments); }
    gtag('js', new Date());

    //conversion tracking for Google Analytics
    gtag('config', 'G-M3WT222222');

    //conversion tracking from Google Ads
    gtag('config', 'AW-12057888501');
</script>
<!-- Event snippet for MYwebsite Purchase conversion page -->
<script>
        gtag('event', 'conversion', {
            'send_to': 'AW-12057888501/x0QzZp_vliJUHNC-B08Zx',
            'value': @ViewBag.Display_subtotal,
            'currency': '@ViewBag.Display_currencyAbbreviation',
            'transaction_id': '@ViewBag.Display_invoiceNumber'
        });
</script>

This is an example of how Shopify does this. Notice the code is wrapped in some liquid code shown here {% if first_time_accessed %}

{% if first_time_accessed %}
<!-- Event snippet for Purchases Shopify conversion page -->
<script>
  gtag('event', 'conversion', {
  'send_to': 'AW-2035565011/frthgrt455_151f5rfc',
  'transaction_id': '{{ order_number  }}'
  });
</script>
{% endif %}

2

Answers


  1. More of a workaround than a solution, but when setting up a new conversion action in Google Ads, there’s the option of restricting ad clicks to only be counted for a single conversion:

    enter image description here

    Of course, changing this option to "One" also means that if someone makes two separate purchases on your site after interacting with an ad, it would still only be counted as a single conversion.

    Login or Signup to reply.
  2. transaction_id field is used to filter out duplicate transactions.

    Make sure it has same value for every page reloading.

    You can’t disable event firing, but it will not affect conversion count.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search