• Skip to main content

Victor Font Consulting Group, LLC

The DEX Intranet Specialists

Call Us:

+1 919-604-5828

  • Home
  • Care Plans
    • Care Articles
    • Optional Subscriptions
  • Consultations
  • Products
    • Code Snippets
    • Public GitHub Repositories
    • Gist Snippets
    • Pastebin Snippets (Free)
    • Free Plugins
  • FAQs
  • Support
    • Graphic Design
  • Contact
    • Speakers
    • Portfolio
  • Resources
    • Free WordPress Video Training
    • Tutorials
    • Articles
    • Cybersecurity
    • EU Referral Network
You are here: Home / Code Snippet / AdWords Call Tracking for Genesis Themes

AdWords Call Tracking for Genesis Themes

By Victor M. Font Jr.
November 10, 20154 Comments

AdWords Call Tracking for Genesis Themes, public domain image from pixabay.com

Tracking phone calls generated from your website is an important metric. How else will you learn how effective your ads are in leading to phone calls from your website that ultimately lead to conversions? Granted, not every call that comes from a website is the result of an ad. Many calls are organic, meaning they've been driven by the site itself and the content you publish. Regardless of the vehicles that lead to a phone call, it's still nice to know how many of those calls result from a click through on your website.

With the addition of Google AdWords Call tracking to your site, you can track calls that originate from your site or mobile devices. The instructions for adding the Google AdWords tracking code to your site are pretty straightforward. Straightforward, that is, if you have a plain vanilla, generic type of website. If you are using a professional developers' tool like the Genesis Framework, Google's instructions may not apply to you. We've written this article to help you install the Google AdWords call tracking code into your Genesis based child theme.

First Method—Don't Try This at Home

One way of attempting to add the code is with the genesis_attr_body filter:

As simple as it is, the problem with the above code is that it doesn't work. When passed through the filter, it does indeed add the AdWords function to the <body> tag. However, it also sanitizes the code and converts the required single quotes within the function into their respective HTML entities (&039). So the resulting HTML looks like this:

It's not very pretty. It definitely won't work. And we haven't been able to find a work-around.

Second Method—JavaScript

While we're not going to repeat anything you can already learn from the Google AdWords Call Tracking site, one thing their site omits is the fact that you can install their function with a JavaScript snippet. The function below is added to your site's header area. In Genesis you can do this in several ways. You can navigate to the Genesis/Theme Settings admin page and copy the code into the header script meta box. You can also add the code through the Genesis Simple Hooks plugin. Or last, you can create code to add the script through your functions.php file.

Third Time's the Charm

The third method, and the one that we prefer, is to add the code directly to header.php. Genesis child themes typically do not have a custom header.php. Header.php is found in the Genesis directory. Since this is core code, you must not under any circumstances edit this file directly. Doing so will create a multitude of problems for you when the Genesis Framework is updated. You can, however, copy header.php into the root folder of your child theme and then edit that file. The code below is an edited header.php from Genesis Version 2.2.3 that you can copy and paste into the child theme directory. Lines 21 and 22 show the modifications. Change the number to your own.

Also note that future versions of Genesis may render this code obsolete. We'll do our best to keep this code updated as new versions of the framework are released.

  • 2shares
  • Facebook0
  • Twitter0
  • Pinterest0
  • LinkedIn2
  • Print
  • SMS0

About Victor M. Font Jr.

Victor M. Font Jr. is an award winning author, entrepreneur, and Senior IT Executive. A Founding Board Member of the North Carolina Executive Roundtable, he has served on the Board of Advisors, of the North Carolina Technology Association, the International Institute of Business Analysis, Association of Information Technology Professionals, Toastmasters International, and the North Carolina Commission for Mental Health, Developmental Disabilities, and Substance Abuse Services. He is author of several books including The Ultimate Guide to the SDLC and Winning With WordPress Basics, and Cybersecurity.

Reader Interactions

VictorFont.com runs on the Genesis Framework

Genesis FrameworkThe Genesis Framework empowers you to quickly and easily build incredible websites with WordPress. Genesis provides the secure and search-engine-optimized foundation that takes WordPress to places you never thought it could go.

Check out the incredible features and the selection of designs. It's that simple—start using Genesis now!

Click here to download The Genesis Guide for Absolute Beginners (PDF - 1.4 MB)

Leave a Reply Cancel reply

Your email address and website will not be published. Required fields are marked *
Posting a comment means that you agree with and accept our Comment & Product Review Policy

Comments

  1. David Alexander

    June 6, 2016 at 2:46 pm

    These guys found a way to escape the characters to get method 1 to work

    http://digitalessence.net/how-to-add-onload-to-the-body-using-genesis-add_filter/

    I personally think method 2 is the best however I have a question about testing. Do you have to find an adwords ad and click it for the onload to appear? or should it appear on every refresh?

    Thanks

    Reply
    • Victor M. Font Jr.

      June 8, 2016 at 5:43 am

      I don’t know about the testing. I don’t use AdWords. I wrote this after someone asked for help.

      Reply
  2. Phil

    December 14, 2015 at 12:34 pm

    Thanks Victor, quick question – why don’t you like method 2? It’s easier to edit the head from the Genesis theme settings in the WordPress backend rather than copying over the header.php file to the child theme because then you don’t have to worry about manually updating the child header.php when there are future updates to the parent header.php. Just wonderin’. Cheers, Phil

    Reply
    • Victor M. Font Jr.

      December 15, 2015 at 7:21 am

      Hi Phil,

      You are right of course. The second method provides longevity, but I never said that I didn’t like preference 2. The goal of the article is to provide a method to accomplish what Google is asking us to do. That is, add the tag to the body markup. If you want it in the body tag, create a custom header.php. Thank you for your insight.

      Reply

Call: +1 919-604-5828

Send us an E-mail

Accessibility Statement | Affiliate Marketing Disclosure | Capability Statement

Cookie Policy | Comment & Product Review Policy | Privacy Policy | Site Map | Terms & Conditions

Copyright © 2003–2023 Victor M. Font Jr.

Return to top of page