Posts tagged with goal-tracking

I've tried many different permutations of gtag and ga codes and I can't seem to get a positive conversion on Google Analytics.

This code runs on form submit and the Google Ad conversion in the first line registers a positive conversion in that platform. Google Analytics is what isn't showing the goal.

I'm NOT using the Google Tag Manager, but including the following global tag.

<script>   window.dataLayer = window.dataLayer || [];   function gtag(){dataLayer.push(arguments);}   gtag('js', new Date());   gtag('config', 'XXXXXXXX'); </script> 

As you can see here the lines I've marked as the attempts are as follows:

// This Google Ad Conversion works properly gtag('event', 'conversion', {'send_to': 'XXXXXXXX'}); // Attempt 1 gtag('event', 'Submit', { 'event_category': 'Form', 'event_label': 'Outdoor Kitchens Landing Oct 2019', 'value': 1 }); // Attempt 2 ga('send', 'event', 'Form', 'Submit', 'Outdoor Kitchens Landing Oct 2019', 1); // Attempt 3 ga('send', {   hitType: 'event',   eventCategory: 'Form',   eventAction: 'Submit',   eventLabel: 'Outdoor Kitchens Landing Oct 2019',   eventValue: 1 }); 

In order to make the ga code work, I had to include the following snippet in the HEAD.

<script>   window['GoogleAnalyticsObject'] = 'ga';   window['ga'] = window['ga'] || function() {     (window['ga'].q = window['ga'].q || []).push(arguments)   }; </script> 

The setup of the goal in Google Analytics is as follows (the label that is cut off reads "Outdoor Kitchens Landing Oct 2019"