I want shortcode to insert a CTA button that says "Request a Quote", but also want it to include onClick event tracking code with the current page title.
This code breaks WordPress (I think it's a problem with single and double quotes)
function my_cta() {
$title = echo get_the_title();
return '<div class="mycalltoaction"><a class="button" href="/contact-us/" onClick="_gaq.push(['_trackEvent', 'QuoteRequest', 'Click', '$title']);">Request a Quote <strong>TODAY</strong></a></div>';
}
add_shortcode('cta', 'my_cta');
What am I doing wrong?