About tracking issues

Home Forums Legacy Support Support queries How-to & Troubleshooting About tracking issues

Viewing 15 posts - 1 through 15 (of 21 total)
  • Author
    Posts
  • #55623
    Eric
    Spectator
    I am using google analytics to track the activity. when starting a course, all course on page"course status", so I couldn't track how many units they visited. Any better way to solve it?   Thanks
    #55999
    H.K. Latiyan
    Participant
    Please try adding this code in your wplms-customizer.php file present in your wplms customizer plugin: add_action('wplms_before_every_unit','track_ajax_unit_views'); function track_ajax_unit_views($id){   ?>     <script>      // Function to track a virtual page view        ga('set', { title: '<?php echo get_the_title($id);?>' });        ga('send', 'pageview');     </script>   <?php }   NOTE: I have not tested this code but it should do the job.  
    #56053
    Eric
    Spectator
    Hi I just try it and looks not working.  Can you help me try if it works on your side.   Regards Eric
    #56224
    MrVibe
    Keymaster
    code updated, please try again.
    #56226
    Eric
    Spectator
    Hi there,   where is the updated code?    
    #56341
    H.K. Latiyan
    Participant
    The code that I shared is the updated code, Mr. Vibe updated my code/reply. So again use the code in my previous reply and let us know if this helps.
    #56385
    Eric
    Spectator
    Hi, I tried and looks no working. still only show page title "course status"
    #56837
    H.K. Latiyan
    Participant
    The reason it may not be tracking is because the function "ga" is not defined when the unit is loaded. The trick is to load part of the Google analytics code in header and part of the google analytics code in the footer. In your google anaylytics code which looks like below code: <script type="text/javascript"> var _gaq = _gaq || []; _gaq.push(['_setAccount', 'UA-XXXXX-X']); _gaq.push(['_trackPageview']); (function() { var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true; ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js'; var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s); })(); </script>   break this up into two parts : Part 1 : To be loaded in Header <script type="text/javascript"> var _gaq = _gaq || []; _gaq.push(['_setAccount', 'UA-XXXXX-X']); _gaq.push(['_trackPageview']); </script>   Part II : To be loaded in footer <script> (function() { var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true; ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js'; var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s); })(); </script> To implement part 1 : add code as shown below: add_action('wp_head','add_ga_code_in_header'); function add_ga_code_in_header(){ ?> <script type="text/javascript"> var _gaq = _gaq || []; _gaq.push(['_setAccount', 'UA-XXXXX-X']); _gaq.push(['_trackPageview']); </script> <?php } To implement part 2: you just need to add the code in WP Admin - WPLMS - Footer - GA section Once you've done this apply the code shared in the previous reply and let us know if it still does not work.
    #56867
    Eric
    Spectator
    I tired as your guide, looks still not working. Is it working on your end?
    #56991
    H.K. Latiyan
    Participant
    No I have not tested it because this can only be tested on the live site so I cannot test it on my test setup (localhost). The method described above is the best way to do this, if its not working then we'll need some time. So please give us some time to check this on our live site. Thanks for patience.
    #58124
    Eric
    Spectator
    thanks. looking forward to your update then.
    #79355
    Eric
    Spectator
    Hi there,   few months past, just check any way can track it now?   thanks Eric
    #79424
    H.K. Latiyan
    Participant
    Sorry for the late reply. Can you please share the details what things you want to track and also share the help link of the tracking code.
    #79463
    Eric
    Spectator
    Hi,  you can check the previous conversation on this post. <span style="color: #4b4d4d; font-family: Lato; font-size: 14px; line-height: 22px;">I am using google analytics to track the activity. when starting a course, all course on page"course status", so I couldn't track how many units they visited.</span><span style="color: #4b4d4d; font-family: Lato; font-size: 14px; line-height: 22px;"> </span>
    #80190
    H.K. Latiyan
    Participant
    based on your request we will try to create a custom plugin for Google analytics which would track this. In case you have more variables to track, please do let us know.
Viewing 15 posts - 1 through 15 (of 21 total)
  • The topic ‘About tracking issues’ is closed to new replies.