Google analytics goal complete when lead capture?

  • 6 November 2010
  • 37 replies
  • 10 views


Show first post

37 replies

Hi Finge,

Your best bet is to track the form submit action as an event. To make this work with Unbounce and Google’s Universal Analtyics, you’ll use their jquery method to tie the action to your button.

So, if, for example, your form’s button ID were #lp-pom-button-16, then you’d replace #button in their example with #lp-pom-button-16, like this:

ga('send', 'event', 'button', 'click', 'nav-buttons');   
}); ```   
 
That should do the trick.
Userlevel 6
Badge +4

Thanks, Ryan! And what if the customer clicks with some required fields not filled out. Will the click be counted as a conversion/goal?

…that, unfortunately, I can’t say for sure. In my own experience using KISSmetrics the answer is unfortunately yes and up till now, I haven’t found a proper solution. I’ve poked around to see if Universal Analytics supports URL goal tracking but haven’t seen anything yet. If they do, that would help avoid those mis-attributed clicks.

Userlevel 6
Badge +4

Ok - so the next question. How do I define this target in GA? I have created a custom goal using event as the goal. Category, label and value are left blank, but in action/event I added ‘click’. However it’s not recording my events?

Hmm. So far as I know, you shouldn’t have to define it. Once you add the tracking it should populate in GA automatically thanks to the “send” parameter. I’d recommend posting in the Google Analytic’s support forum as well. I poked through the even tracking posts but couldn’t see anything that quite describes your situation Finge. Nonetheless, you can find a list of event tracking related issues here and you might notice something I didn’t.

If you do puzzle it out though, I’d love to hear what the solution was.

Hi Ryan and Finge,

I just tried setting up an event on my form submit button and it didn’t seem to work. I’ve found that a better way to track the event is to change the Universal Analytics tag on the form confirmation dialogue page to fire as an event, instead of a pageview.

To do that, you change the line “ga(‘send’, ‘pageview’);” to " ga(‘send’, ‘event’, ‘Category’, ‘Action’, ‘Label’);".

From there, you can make a goal based off that event if you like. (Admin -> Goals -> Event).

I hope that helps!

Hey Bert,
The best way to achieve this would be to use a “Form Confirmation” dialogue when your form is submitted (this is the second tab in the editor when you add a form to your page).

This dialogue acts like any other page, which means you can put scripts on it for firing third party conversions (google adwords, analytics, etc…)

Now I haven’t actually done this myself yet, but here’s how I believe this should work!

Google Analytics goals are URL based, so when you set one up in GA, you’ll have to provide a URL. You’ll need to fake this a bit, but if your landing page was http://mysite.com/mypage then make the goal URL something like " /mypage/formsubmit". It’s important to know that what you name it doesn’t matter as long as you refer to it properly later on.

Now that your goal is set up in GA, go back to your Unbounce page (where I assume you have your GA script embeded using the Javascripts component - if not, check out this knowledge base article) and select the Form Confirmation window for your form (the second tab in the editor)

You’ll want to embed google analytics into this page as well, so follow the same steps as in this article and put your code in the Scripts component. This is where you’re going to edit a line of code to trigger the URL for your goal. The line of code you need to edit in your script will end up looking like:

_gaq.push(['_trackPageview', "/mypage/formsubmit"]);

So your final result should be something like this:

<script type="text/javascript"> <br /><br />
var _gaq = _gaq || []; <br />
_gaq.push(['_setAccount', 'UA-XXXXX-X']); <br />
<strong>_gaq.push(['_trackPageview', "/mypage/formsubmit"])</strong> <br /><br />
(function() { <br />
  var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true; <br />
  ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js'; <br />
  var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s); <br />
})(); <br /><br /> </script>   

Save and republish, and let me know if it works!

Cheers,
Carter

hi Carter,
thanks - will check this out and see if I can get it working!
bert

hi carter,
isn’t it a problem that with the solution you’re suggesting, i include the GA tracker code twice?
one time in the landing page and another time in the “popup page”?
Bert

Hi Bert,
It probably seems a bit confusing having to do it this way, but think about both the main page and the “popup” as two different Unbounce pages – both executing their own set of javascript. You want Google Analytics to know when a visitor comes to your main page, but you also want to track when they see the “popup”. The popup page is actually an iframe, so its scripts will execute in a separate scope than the main page.

Hopefully that’s not too confusing. One day we’ll have proper Google Analytics integration so you can just give us your ID and we’ll take care of the rest…

If you’re still having some trouble, just fire an email to support@unbounce.com with the page in question (mention it’s for Carter to look at) and I’ll take a look.

Cheers,
Carter

hi Carter
I remember reading somewhere that google analytics in an iframe might not work - have you tried it yet?
thanks
B

Hey Bert,
I have not tried the solution that I mentioned above, but I can’t see why google wouldn’t accept a page in an iframe. The issue you may have read about is when you have an iframe with a page on a different domain – the tracking is cookie based so the domains need to match (which they do in our case).

I have set things up for a test page of ours and will let you know the outcome. Have you tried setting things up yet?

Cheers

Reply