in , ,

How to Track Google Ads Conversions with CAOS

Business vector created by freepik

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 Goolge Ads ID to the tracking code. This can be done using a mini plugin.

Request my CAOS Expert Configuration service if you’re not comfortable writing code and/or you need another custom integration. Read more

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';
if (CAOS_OPT_REMOTE_JS_FILE == 'gtag.js') {
add_filter(
'caos_gtag_additional_config',
function() use ($adsId) {
return "gtag('config', '$adsId');";
}
);
}
}
add_action('caos_process_settings', 'caos_google_ads');
view raw caos-google-ads.php hosted with ❤ by GitHub

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.

Written by Daan van den Bergh

Magento 2 Developer by day. WordPress Plugin Developer by night. Wordpress Optimization Super Hero at WoOSH! Passionate about trainlifting, airplane-gliding, hunting trees and creating fake hobbies.

2 Comments

Leave a Reply
  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

    • 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. :)

Leave a Reply

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.