0

I have a .net button which has an onClick event, defined in my C# codebehind to do some work (it sets variables and generates a PDF using itextsharp).

I want to implement a google analytics.js tracking event to this same button. How do I have a button that first fires off the javascript, and then the .net onClick?

3
  • 1
    Duplicate of stackoverflow.com/questions/7477647/…? Commented Jun 21, 2016 at 17:06
  • Ok so that does provide a little more insight. Now I have <asp:Button ID="Button3" runat="server" Text="Create Printable PDF" OnClientClick="TrackPDFGeneration()" OnClick="Button3_Click" UseSubmitBehavior="False" /> and in my script I have: function TrackPDFGeneration(){ ga('send', 'event', { eventCategory: 'ReferralGenerated', eventAction: 'click', eventLabel: 'Create Referral PDF', transport: 'beacon' }); } Am I doing this correctly? The event is not showing up in my Google Analytics. Commented Jun 21, 2016 at 18:06
  • Oh... that worked. It just took a moment to show up. Thank you! Commented Jun 21, 2016 at 18:21

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.