How to Track Google Ads Conversions with CAOS

Recently I received an inquiry on the support forum asking if it is possible to track Google Ads conversions with CAOS.

It appears it is! Using CAOS’ integrated filters it is quite easy to modify the tracking code using a WordPress plugin. Let me show you how you can write your own mini plugin for CAOS.

What is Google Ads?

Google Ads, AKA Google AdWords, is Google’s advertising system in which advertisers bid on certain keywords in order for their clickable ads to appear in Google’s search results. Advertisers pay per click of which publishers get a share.

Tracking conversions is not relevant for you if you are a publisher (the person who’s showing the ads). However, if you’re an advertiser, you’ll want to know how effectively your ad clicks convert. In other words, how your ad clicks lead to valuable customer activity on your website, e.g. purchases, sign-ups and form submissions. That’s why Google allows you to track conversion using Google Analytics.

Enable Conversion Tracking in CAOS

To setup conversion tracking in CAOS, you need to add your Google Ads ID (starting with AW-) to the tracking code. This can be done using a mini plugin.

The snippet of code is really straight forward. It hooks into the recently added caos_process_settings action and adds the specified $optimizeId to its configuration.

Mind you that this snippet will only work with CAOS versions 3.1.0 and higher and gtag.js enabled. (Why gtag.js?)

<?php
/**
* @formatter:off
* Plugin Name: Google Ads for CAOS
* Plugin URI: https://daan.dev/google-adwords-caos/
* Description: Track Google Ads conversions with CAOS.
* Version: 1.0.0
* Author: Daan van den Bergh
* Author URI: https://daan.dev
* License: GPL2v2 or later
* @formatter:on
*/
if (!defined('ABSPATH')) {
exit;
}
/**
* Replace 'YOUR-ADS-ID' with, well, your Google Ads ID.
*/
function caos_google_ads()
{
$adsId = 'YOUR-ADS-ID'; // Starts with AW-
add_filter(
'caos_gtag_additional_config',
function() use ($adsId) {
return "gtag('config', '$adsId');";
}
);
}
add_action('caos_process_settings', 'caos_google_ads');

Simply copy the above code into a file called caos-google-ads.php, insert your Google Ads ID in the position of the placeholder (make sure to place it in between the quotation marks to prevent Syntax Errors) and save it inside WordPress’ plugins-folder, e.g. /path/to/wordpress/wp-content/plugins/caos-google-ads.php. Or, if you want to save yourself the hassle, download this mini plugin for WordPress from Github!

Enable your Google Ads mini Plugin

Now, visit the Plugins screen inside your WordPress Administrator area. You’ll notice a new plugin, called Google Ads for CAOS. Activate it like you normally would and off you go! If you’re using any caching plugins, make sure to flush all caches.

And that’s it! You have now successfully integrated Google Ads into CAOS! I hope this tutorial was clear enough. If you have any remarks or questions, please leave a comment.

❤️ it? Share it!

13 thoughts on “How to Track Google Ads Conversions with CAOS”

  1. I have a question about this AdWords plugin I have been playing with CAOS and Google Ads mini Plugin to see how I can host both scripts locally.

    however, I have found a problem I can host google analytics locally and it works fine but I cannot get the google Adwords script to be hosted locally it keeps sourcing the scripts externally at google servers.

    Does this actually host the google AdWords scripts locally or not?

    thanks
    Rodney

    1. Hi Rodney,

      No, this script doesn’t host the Google Adwords script locally. It just connects Google Analytics to Google Adwords.

      Hosting Google Adwords locally would require a much bigger script. 🙂

      1. Analytics.js should *not* be coming from google but locally – correct?

        Does you pro plugin do this automagically?

        all the best

        1. CAOS does not remove anything. It does not replace anything added by other plugins or themes. It inserts the tracking code for Google Analytics and serves a locally hosted file.

  2. Thanks for this. I have installed this but I see an error in Chrome console

    dev.local/wp-content/uploads/caos/gtag.js?id=AW-738640665&l=dataLayer&cx=c net::ERR_NAME_NOT_RESOLVED

    Seems that it is trying to find the tag not on my website?

  3. Are you sure we have to use for $adsId the account id which is something like 123-456-789 rather than the AW-CONVERSION_ID as described here https://support.google.com/google-ads/answer/6095821?hl=en with gtag(‘config’, ‘AW-CONVERSION_ID’); ?

    Furthermore will this work in the current version of CAOS with these settings: Download file: gtag.js v3 (not V4), Asynchronous Snippet Type and Checked the Enable Stealth Mode Lite?

Leave a Comment

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Shopping Cart
  • Your cart is empty.