• Skip to content
  • Skip to primary sidebar

Michael Rassel

Web Developer

Adwords Call Forwarding in Google Tag Manager

October 11, 2016 by Michael Rassel

Get your conversion code from adwords.

Define a CSS selector for the HTML element that contains the phone number to be converted.

Create a new tag in GTM
Select a tag configuration of Custom HTML <>
Paste the JS conversion code into the textarea.
Define a trigger of All Pages.

Just before the closing tag, paste the number replacement script:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
//Change the values in this section to customize for your implementation.
 
//Replace with business's phone number EXACTLY as it appears on the website.
var business_number = "(555) 555-5555";
 
//Replace with business's phone number without spaces or symbols.
var business_number_unformatted = "5555555555";
 
//Replace this value with the CSS selector for the phone number's element.
var business_number_identifier = "h2.site-description";
 
//End customization section
 
var callback = function(formatted_number, unformatted_number) {
var numberElement = document.querySelector(business_number_identifier);
var numberString = numberElement.innerHTML;
numberString = numberString.replace(business_number,formatted_number);
numberElement.innerHTML = numberString;
};
 
//The line of code below is for testing with GTM's debug mode.
//It replaces the business phone number with a testing number (666-666-6666).
window.onload = callback('666-666-6666', business_number_unformatted);
 
//This code executes everything. When you're done testing and you're ready to publish the
//GTM container, place '//' in front of the code above, and remove the '//' below.
//window.onload = _googWcmGet(callback, business_number);

Save the tag and select GTM’s Preview and Debug mode. Then test the website. If the tag is configured successfully, the phone number should be the debug number:666-666-6666.

Now disable the debug number and activate the Google number:

1
2
3
4
5
Comment this:
//window.onload = callback('666-666-6666', business_number_unformatted);
 
Uncomment this:
window.onload = _googWcmGet(callback, business_number);

Publish Tag Manager and conclude the task.

Filed Under: Web Dev Tagged With: Adwords Call Conversion, Tag Manager

Primary Sidebar

Recent Posts

  • Gravity Forms Google Analytics tracking in Tag Manager
  • SSL htaccess redirect
  • CSS Clearfix with Pseudo Selector
  • Woocommerce Logged in Only
  • Repsonsive Video embed
  • Add robots meta tag to specific page
  • Youtube Responsive JS embed
  • Disable Cache while Chrome Developer Tools is open
  • Import CSV to PHPMyAdmin
  • Adwords Call Forwarding testing
  • Google Tag Manager in Genesis Theme
  • Woocommerce Widget Featured Product by Category
  • WordPress Disable Password Change Nofitication
  • Reposition Genesis header right widget
  • Center text over image
  • JS Full Window Height
  • Allow Iframe but restrict direct access
  • Show excerpt on Woocommerce archive list
  • Woocommerce default shipping selection
  • Remove Images from WooCommerce pages

Tags

Adwords Call Conversion Logged in users only Open Office remove empty rows role restriction Tag Manager web design terms Woocommerce Wordpress menu class

Categories

  • Music (2)
  • Web Dev (36)
    • Magento (1)
    • Wordpress (15)

Copyright © 2019 · Magazine Pro on Genesis Framework · WordPress · Log in