Google Ads (Adwords) Conversion Code Setup

Set up conversion tracking for Google Ads with a simple, unified code setup that works seamlessly across campaigns and platforms.

Ceyhun Enki Aksan
Ceyhun Enki Aksan Entrepreneur, Maker

Google Analytics tracking via Analytics.js has long been shared with users through the Global Site Tag by default.

The Global Site Tag, integrated with the dataLayer object used across applications such as Google AdWords and Google Analytics, enables rapid service linking and tracking through a single code snippet, via its config parameter. As of June 2018, Google Ads—developed in conjunction with the Google Marketing Platform—now offers enhanced features and a refreshed dashboard1 2. Alongside the new interface, it has also become possible to use Google Ads conversion and remarketing code via the Global Site Tag3.

tip

Support requests for Google Analytics and Google Tag Manager can be found here.

In the latest update, GTAG is now provided by default. Previously, I published a blog post titled “What is the Global Site Tag (gtag.js)?” outlining how services like Google Analytics and Google Ads can now be tracked in a unified structure with the Google Tag Manager architecture. As I mentioned in that article, by simply entering ID values through the config parameter, these services can now be quickly integrated into our websites and applications via a single code snippet. In this article, I will also explain the process prior to integration, including how to obtain the conversion code and, of course, the ID values.

Play

Of course, I assume you are familiar with the Google Ads service and have access to an account. You can also create a new account. For assistance with the account creation process, please refer to the help page4, and you can learn how the system works from the How It Works page5.

Google Ads
Google Ads

Once you’ve created your account and/or gained access to an existing one, the new interface uses the topbar (the gray menu in the top section of the site) for actions such as Setup and Library, Rules, and Measurement. To access the area where conversion codes are created, you’ll navigate via the Conversions link under the Measurement section. If you haven’t previously created a conversion code, a welcome screen will appear, and you can proceed to the next page using the quick link provided. If you’ve already created a conversion code, you’ll be directed to the standard page that lists your conversion codes (accessible both immediately and after the quick link).

Google Ads
Google Ads

When creating a conversion code, you will be asked to specify the type of conversion code, just as in the previous interface. Selecting the “Website” option from the available choices—Website, App, Phone Calls, and In-App—will suffice.

Google Ads Conversion Code
Google Ads Conversion Code

In the next step, you can assign a name to your conversion code and define its properties, including the important Value and Count fields. The Value field is a parameter that determines how the conversion will be reflected each time the conversion code is triggered. For example, if you’re treating a conversion as an action—such as form submission or page view—you can select a fixed value (such as a single price or number), or you can proceed with the Use Value option. If you’d like to assign a dynamic price for each conversion (for instance, when calculating the ad performance and evaluating each conversion as a separate parameter), you can assign different values (such as product prices) for each conversion.

Google Ads Conversion Code Setup
Google Ads Conversion Code Setup

The Count field ensures that the number of user-initiated conversions is properly tracked. For instance, if you select the Each option, each time a user performs the action defined as a conversion, the conversion count will increment. This can include various actions such as form submissions, product purchases, or page views. On the other hand, if you select the One option, the conversion will be counted only once, regardless of how many times the user performs the action. This is particularly recommended for actions such as request forms or account sign-ups. You can customize the other fields in this section according to your needs.

Ad Conversion Label
Ad Conversion Label

After filling in the required fields, it’s time for our conversion code and/or tag to be assigned to you. After this step, you will receive an ID value starting with AW- that is compatible with the new GTAG format. If your website and/or app already has a Google Tag Manager installation, you can obtain the ID (Conversion ID) and Label (Conversion Tag) values by selecting the Use Google Tag Manager option. In this case, you should remember that the first portion of the AW-123456789/AbC1DE_FgghIJKL2m3NO structure (AW-123456789) refers to the Ads (AW) and the conversion ID (123456789), while the second portion (AbC1DE_FgghIJKL2m3NO) specifies the conversion ID.

Ads Conversion ID
Ads Conversion ID

If you select the Load the tag yourself option, you will be provided with the GTAG code. This code must function across all your pages. If you have not previously added the Google Analytics code to your site using the Global Site Tag, you can simply insert it directly into the <head>…</head> section of your page’s source code.

 window.dataLayer = window.dataLayer || [];
  function gtag(){dataLayer.push(arguments);}
  gtag('js', new Date());

  gtag('config', 'AW-123456789');

If your Analytics code is already present via GTAG, you only need to add your conversion ID with a new config parameter to the relevant line. In the code above, our conversion ID is 123456789. The AW value indicates that this ID belongs to a Google Ads account. The Google Analytics account value, on the other hand, begins with UA and then takes the property value.

 window.dataLayer = window.dataLayer || [];
  function gtag(){dataLayer.push(arguments);}
  gtag('js', new Date());

  gtag('config', 'UA-12345678-1');

Google Analytics website tracking code looks as follows. As you can see, aside from the config parameter and script path https://www.googletagmanager.com/gtag/js?id=UA-12345678-1, everything else remains the same. The script path itself has no significance, so it can load UA, GA4, AW, and GTM values. What matters is that the identity values of the accounts for which data streams are established must be defined in the config.

 window.dataLayer = window.dataLayer || [];
  function gtag(){dataLayer.push(arguments);}
  gtag('js', new Date());

  gtag('config', 'UA-12345678-1');
  gtag('config', 'G-123456789');
  gtag('config', 'AW-123456789');

My recommendation is to set up the other accounts after UA. This way, tracking will be easier. If you’d like to add multiple Google Analytics and Google Ads accounts, you can simply include each one in new lines under the config parameter. Of course, you must verify the functionality using Google Tag Assistant.

Google Tag Manager - Ads Setup
Google Tag Manager - Ads Setup

Once you’ve created your code, generated the relevant snippet, and placed it in the source of your pages so that it runs across all your pages—great job! From this point on, the Retargeting feature will also be activated, and you won’t need to perform any additional setup. However, we’ll need to include an additional code snippet for conversion tracking.

Google Ads - Click Conversion Setup
Google Ads - Click Conversion Setup

If we want the conversion to occur when a page is viewed (e.g., product page, form page, redirect page, thank-you page, payment result page, etc.), we should select the Page View option and add the generated code beneath our GTAG code.

 window.dataLayer = window.dataLayer || \[\];
  function gtag(){dataLayer.push(arguments);}
  gtag('js', new Date());

  gtag('config', 'AW-123456789');
 gtag('event', 'conversion', {'send_to': 'AW-123456789/AbC1DE_FgghIJKL2m3NO'});

The code will run when the relevant page is loaded, triggering the conversion process. Alternatively, the conversion can occur upon a user interaction (such as clicking a link or button). When you select the click event as your trigger, we will place the code you receive as a conversion snippet directly beneath our GTAG code.

Google Ads Conversion Setup
Google Ads Conversion Setup

Finally, for a click event (such as onClick, onFocus, onHover, etc.), we will create a trigger and add the function to the relevant element.

 window.dataLayer = window.dataLayer || \[\];
  function gtag(){dataLayer.push(arguments);}
  gtag('js', new Date());

  gtag('config', 'AW-123456789');
 function gtag_report_conversion(url) {
  var callback = function () {
    if (typeof(url) != 'undefined') {
      window.location = url;
    }
  };
  gtag('event', 'conversion', {
      'send_to': 'AW-123456789/AbC1DE_FgghIJKL2m3NO',
      'event_callback': callback
  });
  return false;
}

For the example, let’s assume we have a Submit button.

<form>
...
<input type="submit" value="Submit">
</form>

We want the conversion to occur when this button is clicked. The addition we’ll make will be: return gtag_report_conversion(url). The url parameter within the function will specify the page path to redirect to after the conversion process is completed.

<form>
...
<input type="submit" value="Submit" onClick="return gtag_report_conversion('https://ornekwebsitesi.com/homepage/')">
</form>

Footnotes

  1. Google Marketing Platform
  2. Google Ads
  3. Upgrade analytics.js
  4. Create a Google Ads account: How to sign up
  5. How It Works. Google Ads