rdyar / LabWOES

Unofficial ROES and LabWorks support for Photo Labs
https://rdyar.github.io/LabWOES/
1 stars 1 forks source link

Using Google Analytics to track roes launches #62

Open rdyar opened 8 years ago

rdyar commented 8 years ago

I've been playing around with tracking clicks on our ROES Launch links for a while, and now with the webview stuff for the main splash screen in 9.5 I am able to add tracking to actual roes launches.

To track a successful roes launch, I added this to the bottom of the html for my main splash page:

<script>//google tracking - plp - need to update for others
                     (function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
      (i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
      m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
  })(window,document,'script','https://www.google-analytics.com/analytics.js','ga');

                     ga('create', 'UA-xxxxxxx-x', 'auto');
                    ga('send', 'event', {
                    eventCategory: 'ROES-Launch-successful',
                    eventAction: 'click',
                    eventLabel: 'hooray'
                  });    
</script>

Replace the xxxxxxx-xx with your ga account number. I think you can put whatever you want in the category/actions and label. Hooray was just cause I couldn't think to put anything else.

To track clicks on the launch links on your website you can do the link like this:

  <a title="Download ROES for macs" href="http://www.roeslaunch.com/ROES/labs/youtlabname.dmg"  onclick="trackOutboundLink('http://www.roeslaunch.com/ROES/labs/yourlabname.dmg'); return false;">

and then on your page you need the script below in addition to your normal ga code:

 <script>
              var trackOutboundLink = function(url) {
               ga('send', 'event', 'outbound', 'click', url, {'hitCallback':
                 function () {
                 document.location = url;
                 }
               });
            }
        </script>

They both seem to work well, though I just started doing the one in the webview splash page.