Guys, I have a quick question. I'm wondering if you guys and tell me if this looks correct to you. I'm setting up Google Dynamic Call Tracking (GDCT) and deploying this through Google Tag Manager (GTM) and I really don't have an easy way to test this out.
Here's the HTML
<li class="tel phone1">
<span class="type">Sales</span>
<span class="separator">:</span>
<span class="value">(888) 224-8350</span>
</li>
I know that this JS will return the actual phone number.
mynum = document.getElementsByClassName('tel phone1')[0].getElementsByClassName('value')[0].innerHTML;
<script>
(function(a,e,c,f,g,b,d){var h={ak:"996234153",cl:"RguGCL6AgVYQqaeF2wM"};a1=a1||function(){(a1.q=a1.q||[]).push(arguments)};a[f]||(a[f]=h.ak);b=e.createElement(g);b.async=1;b.src="//www.gstatic.com/wcm/loader.js";d=e.getElementsByTagName(g)[0];d.parentNode.insertBefore(b,d);a._googWcmGet=function(b,d,e){a1(2,b,h,d,null,new Date,e)}})(window,document,"_googWcmImpl","_googWcmAk","script");
jQuery(document).ready(function() {
_googWcmGet('number', 'X-XXX-XXX-XXXX');
});
</script>
Their example on that website:
"you need to define your phone number on your site in this format: <span class=”number”>X-XXX-XXX-XXXX</span>"
My question is for my website, given the example HTML above would the function be something like this?
mynum = document.getElementsByClassName('tel phone1')[0].getElementsByClassName('value')[0];
_googWcmGet(mynum, 'X-XXX-XXX-XXXX')
Or like this?
mynum = document.getElementsByClassName('tel phone1').getElementsByClassName('value');
_googWcmGet(mynum, 'X-XXX-XXX-XXXX')
Or do you think I can just pass the main class name "tel phone1" and that will work like this
mynum = document.getElementsByClassName('tel phone1');
_googWcmGet(mynum, 'X-XXX-XXX-XXXX')
From my understanding of the other website, the script from google will loop through page and replace all the instances of the matching phone number on the page that matches "x-xxx-xxx-xxxx".
[edited by: engine at 5:29 pm (utc) on May 13, 2015]
[edit reason] Please see WebmasterWorld TOS [/edit]