Advertisement
FiringBlanks

Google Ads Conversion Event Trigger - Sign Up

Jun 15th, 2022
1,019
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
HTML 5 0.85 KB | None | 0 0
  1.   triggerSignUpGtag(){
  2.     console.log('Running triggerSignUpGtag()');
  3.     // Event snippet for Purchase (1) conversion page
  4.       // In your html page, add the snippet and call gtag_report_conversion when someone clicks on the chosen link or button.
  5.         // register google analytics
  6.         const gaScript = document.createElement('script');
  7.         gaScript.innerHTML = `
  8.         <script>
  9.         function gtag_report_conversion(url) {
  10.           var callback = function () {
  11.             if (typeof(url) != 'undefined') {
  12.               window.location = url;
  13.             }
  14.           };
  15.           gtag('event', 'conversion', {
  16.               'send_to': 'AW-773026615/gGhTCNjyvMUDELfmzfAC',
  17.               'event_callback': callback
  18.           });
  19.           return false;
  20.         }
  21.         </script>`;
  22.         document.head.appendChild(gaScript);
  23.   }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement