How to trigger Goals for form thank you pop up


#1

Can anybody tell me how to set up a goal to capture when a form is filled out and the thank you lightbox pops up to say thank you?

I am using unbounce and there is a place for me to put script into the head tag. But I don’t understand how to set it up.

Thank you,

David


(Lukas Winkler) #2

Hi,

You can trigger goals from Javascript:

https://developer.matomo.org/guides/tracking-javascript-guide#manually-trigger-goal-conversions

It is basically just calling _paq.push(['trackGoal', 1]); if your goal id is 1.


#3

Hi Lukas,

Thank you, but now I’m even more confused.

I’m guessing I place this snippet of code in the rest of the matomo code?

The goal ID of 1, how does the connection get made?

Thanks,

David


(Lukas Winkler) #4

Hi,

You don’t place the snippet in the rest as that way it would get executed on site load. You add it to the javascript function that gets executed when the pop up opens.


#5

Hi Lukas,

Here is what I put in the code that goes on all the pages:

<script type="text/javascript">
  var _paq = _paq || [];
  /* tracker methods like "setCustomDimension" should be called before "trackPageView" */
  _paq.push(['trackPageView']);
  _paq.push(['trackGoal', 1]);    <<<--------- I added it here.
  _paq.push(['enableLinkTracking']);
  (function() {
    var u="//datastreamanalytics.com/";
    _paq.push(['setTrackerUrl', u+'piwik.php']);
    _paq.push(['setSiteId', '6']);
    var d=document, g=d.createElement('script'), s=d.getElementsByTagName('script')[0];
    g.type='text/javascript'; g.async=true; g.defer=true; g.src=u+'piwik.js'; s.parentNode.insertBefore(g,s);
  })();
</script>
<noscript><p><img src="//datastreamanalytics.com/piwik.php?idsite=6&rec=1" style="border:0;" alt="" /></p></noscript>

So now I am collecting conversion but it looks like I’m getting triple for each conversion.

How should I configure the back end when setting up a goal?

Question 2.

Are you saying I should just place this by itself like this below:

_paq.push([‘trackGoal’, 1]);

Into popup dialog, or do I add the whole tracking code?

Lukas thank you for you help!

David


#6

Lukas,

This is what I did:

<script type="text/javascript">
_paq.push(['trackGoal', 3]);
  </script>

Is that correct?