Execute Javascript on click through


#1

I’m using a click through template and when some clicks through my landing page, I would like that to register as a conversion in Facebook and Google Analytics. Both FB and Google provide javascript code that they ask you to place on a “Thank you” page, but in this case there is no thank you page. People just click on a button and are taken to an external site.

Is there a way I can get this Javascript code to execute when someone clicks on the button?


#2

Hey there Jeremy!

What you will want to do is place the conversion script on the last page of your funnel, so if you want to mark a conversion when someone clicks a button, you will want to add the script to the page that is loaded when the button is clicked. 

However it is possible to fire the script when the button is clicked. See below for an example script to use. You will want to replace #lp-pom-button-11 with the ID of the button your landing page.

$('#lp-pom-button-11').click(function () { 



Place conversion tracking script here

    });

Feel free to send us an email at support@unbounce.com with any questions :slight_smile:


Facebook event code fire on image click?
#3

Rockstar. Thanks Meghan!


#4

If I want this to work for all buttons, can I replace the button id with the class:

.lp-pom-button