Send an event to Analytics when a FAQ entry is expanded
$10-30 AUD
Completed
Posted about 7 years ago
$10-30 AUD
Paid on delivery
I am trying to work out which FAQs from our site are the most popular. I thought using GA would be the best way, so tried to use some of the existing JQuery that the user clicks to Open a question would be reusable:
<div class="faq">
<div class="question" id="q<?= $i; ?>">
<?php the_sub_field('faq_question'); ?>
<span class="ico icon-chevron-right"></span>
</div>
<div class="answer">
<?php the_sub_field('faq_answer'); ?>
</div>
</div>
and
<script>
jQuery(document).ready(function(){
jQuery('.faq').click(function() {
jQuery(this).toggleClass('open');
});
});
</script>
I tried adding
<!-- dodgy new code starts here -->
var linkText = $(this).html();
alert(linkText);
ga('send', 'event', 'FAQ', linkText);
<!-- end dodgy new code -->
into the script, but it includes the whole Question and Answer. When rendered on the page, the html displays as:
<h3>General FAQ</h3>
<div class="faq">
<div class="question" id="q1">
How many roads must a man walk down, before you can call him a man?
<span class="ico icon-chevron-right"></span>
</div>
<div class="answer">
<p>The answer is "blowing in the wind".</p>
</div>
</div>
I want to create an event that shows which FAQ entry has been clicked.
Hello
I am a Jquery and JavaScript expert
I have 6 years of experience in this field.
I have the knowledge of Google analytics and how to integrate it the project.
so I am interested to work on this project.
Thanks
Kush
$40 AUD in 1 day
4.8 (21 reviews)
4.4
4.4
7 freelancers are bidding on average $34 AUD for this job
We are team of excellent developers. We have 2 year experience related to your project field. We can do your project and solve your all problems according to your requirements. We have read your description for projects and we understand what you want so we are confident that we can do it easily in mention time. We assure you that you will be completely satisfy with our work. And after delivering your project if you feel some issue in understanding the projects then we will teach you free until you understand.
If you have any question then feel free to ask. We are here for you.
Thank you
Demon Developer Team