Google Conversion Tracking code
-
I followed the directions on Google Adwords, which told me to go to my child theme and add some code. (actually I used this site too: https://kinsta.com)
Here is the error it returned:
syntax error, unexpected ‘<‘, expecting end of fileHere is the code I tried to put into the child theme’s function.php file. Apparently this is how you put the code in the Head area.
/* Google Adwords conversion tracking */ <!-- Global site tag (gtag.js) - Google Ads: 981117273 --> <script async src="https://www.googletagmanager.com/gtag/js?id=AW-xxxxxxxx"></script> <script> window.dataLayer = window.dataLayer || []; function gtag(){dataLayer.push(arguments);} gtag('js', new Date()); gtag('config', 'AW-981117273'); </script> <!-- Event snippet for TofA tracking 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-xxxxxxxx/xxxxxx', 'event_callback': callback }); return false; } </script>
I tried to ask in the Google Community but it saw the code and would not allow me to upload it. It gave me an error message and would not allow me to post. So WP does not like it and Google Community does not like it too.
Any ideas how I can make this work, or do I have to get a “tag” plugin?
This is line 29:
<!– Global site tag (gtag.js) – Google Ads: 981117273 –>It is the line that WP calls out as bad, it is possible there is more if WP saw the first error and did not check the rest of the file.
How do I fix it, please?
Thanks for considering this question
- This topic was modified 5 years, 11 months ago by .
- This topic was modified 5 years, 11 months ago by .
- This topic was modified 5 years, 11 months ago by .
- This topic was modified 5 years, 11 months ago by .
The page I need help with: [log in to see the link]
- The topic ‘Google Conversion Tracking code’ is closed to new replies.