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.
Is this still necessary? Assuming it is, but just wanted to confirm since the Githib hasn’t been updated in 4 years
Hi!
Yes, I recently updated it to be compatible with GA4 and the current version of CAOS (Pro).