/

  / 

How to Use Marchex JavaScript Rewrite in Google Tag Manager

Yes, you can use the Marchex JavaScript rewrite in Google Tag Manager. Here's how it's done.

Create a JavaScript Rewrite

In Marchex, create your JavaScript rewrite. Of course, be sure to specify the referring domain for use later in your _vsrefdom URL parameter. [gallery ids="7381,7379,7380"]  

 Copy the JavaScript Rewrite Script

Scroll to the bottom of the JavaScript Rewrites page. Copy the code. marchex4  

Modify the JavaScript Rewrite Code

Change the src attribute from:
src="//adtrack.voicestar.com/euinc/number-changer.js"
to:
src="//adtrack.voicestar.com/euinc/number-changer-gtm.js"

Create Account in Tag Manager

[gallery ids="7384,7385"]

Install the Tag Manager Script

Google recommends placing the code just after the opening <body> tag. However, Tag Manager and the contained Marchex tag will work regardless of where on the page the Tag Manager code is placed. In other words, ideally you'll have the the Tag Manager code placed in the recommended location. But if it has to be placed somewhere else on the page (e.g. between the <head></head> tags or at the bottom of the page), both Tag Manager and the Marchex rewrite will still work. tm3

Create the Tag and Trigger

  1. Name the tag "Marchex"
  2. Select "Custom HTML Tag"
  3. Paste your modified Marchex code into the "HTML" text area
  4. Select "Support document.write"
  5. Under "Fire On," click "More"
  6. Name the trigger "Page Load"
  7. Choose "Page View" as the Event
  8. Configure the trigger. Select "Window Loaded"
  9. Set "Fire On" to "All Page Views"
  10. Save the trigger and apply it to your tag
  11. Save your tag
[gallery ids="7388,7389,7390,7391,7392,7393,7394"]

Test Tag Manager and Marchex

Once the Tag Manager code has been installed, you will want to test it to make sure it's functioning properly.
  1. Enter "Preview" mode
  2. Open a new tab in the same browser and visit the URL you wish to test (including the _vsrefdom parameter, e.g. www.meindlmotors.com/?_vsrefdom=test)
  3. If configured properly, the Marchex tag should fire on the "Page Load" event (and only on the "Page Load" event), and all corresponding textual phone numbers on the page should be rewritten.
[gallery ids="7395,7396"]