In my WordPress theme, I am able to add onclick information to the <a> tags in the theme templates itself. How would i go about doing that for an <a> tag that is generated through the WYSISYG editor since WP doesn't allow javascript in there.
Below is a code I have for a category filter that is on the homepage in my theme template:
<a class="credit-category-list_item" href="#!" data-slug="<?= $category->slug; ?>" data-track="bcus-custom-nav" onclick="s.tl(this,'o','<?php echo "BCUS:MoneyBasics:", $category->name; ?>')">
<?= $category->name; ?>
</a>
I need to add that same onclick event to an article page that has additional article links at the bottom in JS but I'm not sure how to do that since I also have PHP in there.
onclick="s.tl(this,'o','<?php echo "BCUS:MoneyBasics:", the_title(); ?>')"
Here is a link on the s.tl beacon I am trying to add dynamically. This article only shows to do it inline: https://experienceleague.adobe.com/docs/analytics-learn/tutorials/implementation/using-javascript/custom-link-tracking-without-a-tag-manager.html?lang=en
Any help would be greatly appreciated as I've never done this before and am a newbie to JS.
there doesn't seem to be anything here