Hi.
This is the code the Google ads rep sent me to use.
- Install the global site tag on every page of your website.
- Open the HTML for each page.
- Choose from the following options:
* If you haven’t installed the global site tag on your website, copy the tag below and paste it between the head
tags ( <head></head>
):
<!-- Global site tag (gtag.js) - Google Ads: 942669475 --> <script async src="https://www.googletagmanager.com/gtag/js?id=AW-942669475"></script> <script> window.dataLayer = window.dataLayer || []; function gtag(){dataLayer.push(arguments);} gtag('js', new Date()); gtag('config', 'AW-942669475'); </script>
See more guidelines on setting up the global site tag.
* If you installed the global site tag on your website from another Google product (example: Google Analytics) or from another Google Ads account, copy the ' `config` ' command below and add it to every instance of the global site tag, right above the `</script>` end tag.
gtag('config', 'AW-942669475');
* If you or a manager account already installed the global site tag on your website while setting up the tag for another conversion action, make sure that the tag is on every page of your website and check that the ' `config` ' command has this Google Ads account's conversion ID: `AW-942669475`
-
Save the changes to your webpages.
-
Install the event snippet on the page that has the button or link you’d like to track.
-
Open the HTML for the page.
-
Copy the snippet below and paste it between the head
tags ( <head></head>
) of the page, right after the global site tag.
<!-- Event snippet for Book appointment conversion page In your html page, add the snippet and call gtag_report_conversion when someone clicks on the chosen link or button. --> <script> function gtag_report_conversion(url) { var callback = function () { if (typeof(url) != 'undefined') { window.location = url; } }; gtag('event', 'conversion', { 'send_to': 'AW-942669475/kz7MCMqjm_MBEKP9v8ED', 'event_callback': callback }); return false; } </script>
- Add an
onclick
attribute directly to the code for the button or link you’d like to track. The code you use will depend on how the link or button is displayed on your site: as a text link, button, or button image.
Add the code to a text link: In the code below, replace “http://example.com/your-link” with the URL for your website or telephone link, and replace “Download now!” with your link text.
<a onclick="return gtag_report_conversion('http://example.com/your-link');" href="http://example.com/your-link">Download now!</a>
Add the code to a button: This code shows you how to add click tracking functionality to a button using the <button>
tag. Replace “http://example.com/your-link” with the URL for your website.
<button onclick="return gtag_report_conversion('http://example.com/your-link')">Submit</button>
Add the code to a button image: In the code below, replace “download_button.gif” with your button image, replace the width
and height
with your image’s parameters, and replace “http://example.com/your-link” with the URL for your link.
<img src="download_button.gif" alt="Download Whitepaper" width="32" height="32" onclick="return gtag_report_conversion('http://example.com/your-link')" />
- Save the changes to your webpage.