Skip to main content

Track Phone Conversions for Multiple Store Locations

Track Google Ads phone call conversions for several store locations, each with its own phone number and conversion label, instead of the single number you can configure in the Pixel Manager settings.

When you need this recipe

The Pixel Manager's Phone Conversion Number setting holds one number and one conversion label. If you run multiple locations (for example a store with seven branches, each with its own phone number), you need a different number and conversion label per location. This recipe wires that up through the Pixel Manager's Command Queue and consent handling, so each location's number is tracked at the right time and only after consent.

Google tracks one number per page

Google's website call tracking swaps a displayed phone number for a Google forwarding number to attribute calls to ad clicks. With the standard gtag JavaScript, this is limited to a single number per page. Google states it directly:

Only one number can be tracked on a single page using the default Javascript tag.

Source: Set up tracking calls to a phone number on a website (Google Ads Help).

So the supported model is one tracked number per page: give each location its own page and map that page to its number. Showing several numbers on one shared page is covered further down.

Before you start

  1. In Google Ads, create one "Calls from a website" conversion action per location. Each gives you a conversion label, so the full conversion target for a location looks like AW-123456789/AbCdEf123.
  2. Give each location its own page that displays that location's phone number.
  3. Leave the Phone Conversion Number and Phone Conversion Label fields in the Pixel Manager settings empty, since this recipe handles all locations.

Recipe

Add the following to your child theme's functions.php. Fill in the $locations map (one row per location page) and adjust the is_page() matching to your pages.

/wp-content/themes/child-theme/functions.php
add_action( 'wp_head', function () {

// One entry per location page (page => the number shown on it + its conversion target).
$locations = array(
'contact-new-york' => array( 'number' => '+1 212-555-0100', 'label' => 'AW-123456789/AbCdEf123' ),
'contact-boston' => array( 'number' => '+1 617-555-0100', 'label' => 'AW-123456789/GhIjKl456' ),
'contact-chicago' => array( 'number' => '+1 312-555-0100', 'label' => 'AW-123456789/MnOpQr789' ),
// ... add the remaining locations
);

// Pick the entry for the current page (adapt the matching to your site).
$entry = null;
foreach ( $locations as $page => $data ) {
if ( is_page( $page ) ) {
$entry = $data;
break;
}
}

if ( null === $entry ) {
return;
}
?>
<script>
window._pmwq = window._pmwq || [];
window._pmwq.push( function () {
var phoneNumber = <?php echo wp_json_encode( $entry['number'] ); ?>;
var conversionLabel = <?php echo wp_json_encode( $entry['label'] ); ?>;

// gtag and consent both arrive asynchronously, so check every 300ms
// until ready, then fire once. Covers normal load, lazy load and late consent.
var tries = 0;
var poll = setInterval( function () {
if ( ++tries > 200 ) { clearInterval( poll ); return; } // give up after ~60s
if ( typeof window.gtag !== 'function' ) { return; } // gtag not loaded yet
if ( ! pmw.googleConfigConditionsMet || ! pmw.googleConfigConditionsMet( { type: 'marketing' } ) ) { return; } // no consent (yet)
gtag( 'config', conversionLabel, { phone_conversion_number: phoneNumber } );
clearInterval( poll );
}, 300 );
} );
</script>
<?php
}, 1 );

The number must match the number exactly as it appears on the page (same digits and format), so Google's dynamic number insertion can find and swap it.

How it works

  • Command Queue (window._pmwq) runs the code as soon as the Pixel Manager API is available, no matter how or when the plugin loads (including script deferral and lazy loading).
  • The poll handles the fact that gtag is created asynchronously and that consent may be granted late. It checks every 300ms until both window.gtag exists and consent is in place, fires once, then stops (with a safety cap of about 60 seconds).
  • Consent is gated through the same check the Pixel Manager uses for its own Google Ads conversions (pmw.googleConfigConditionsMet({ type: 'marketing' })). When Google Consent Mode is active this returns true and gtag handles consent; when it is not, the call fires only after marketing consent. A phone call conversion is a marketing signal, so marketing is the correct category.

Tracking several numbers on one page

If you want to show all of your locations' numbers on a single shared page, the standard gtag tag cannot track them. Google's guidance for that case is the advanced manual install or Google Tag Manager:

You should use this option if you want to track calls to multiple phone numbers on your website.

(from the same Google Ads Help page). That path is outside the scope of this recipe; the per-page setup above is the recommended approach.

Troubleshooting

  • The number is not being swapped. Confirm the number matches the digits shown on the page exactly. You can test Google's swapping by appending #google-wcc-debug to the page URL.
  • Nothing fires. Make sure the page is matched by your is_page() logic, and that the Google Ads pixel is active in the Pixel Manager. The snippet only fires after marketing consent is granted.
  • The conversion is attributed to the wrong location. Each location needs its own conversion action (its own label) in Google Ads, and its own page.

Make more money from your ads with high-precision tracking