OnClick In WP Text Block

Posted in: Newspaper
Post count: 19

I’m using the WP Text Block to display custom ads on my sites homepage and post pages. (See http://www.moodlenews.com)

I’d like to use the onclick event from Google to track outbound links, but when I add it to the anchor tag in the WP Text Block, it is removed upon update/save.

I have two ads that display a the top of all pages that I’ve implemented through the “Ads” section of the theme panned. The onclick script works there.

Is there a way to make the onclick event work in the WP Text block as well?

Post count: 22421

Hello,

WordPress is stripping the code from the textblock. It is a default behavior of WP.
You can maybe use a plugin for this: https://wordpress.org/plugins/gravitate-event-tracking/
Or you can maybe find a ‘non plugin’ solution online:
https://wordpress.org/support/topic/wp-edit-preventing-wordpress-from-stripping-out-onclick-javascript
https://www.quora.com/How-do-I-get-WordPress-to-stop-removing-my-OnClick-events-when-I-use-the-visual-editor

I hope this helps!

Post count: 19

Thanks, Bogdan. I was hoping you had an internal/theme specific solution for this 🙂 But thank you for the resources you’ve pointed out.

Viewing 3 posts - 1 through 3 (of 3 total)
The forum ‘Newspaper’ is closed to new topics and replies.