SitePoint Sponsor

User Tag List

Results 1 to 2 of 2
  1. #1
    SitePoint Evangelist Caesar's Avatar
    Join Date
    May 2000
    Location
    On some harddisk
    Posts
    599
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    JavaScript newbie - Am I doing this right? Setting up MixPanel.

    On my wordpress page, I've got this right at the top:

    Code:
    <script type="text/javascript">
        mixpanel.track(
        "AESML page"
    );
        mixpanel.track_links("#aesml-i", "Click AESML link", {
            "referrer": document.referrer
        });
    </script>
    And somewhere below on the page, I've got:

    Code:
    <div id="aesml-i" align="center"><a href="http://website.com/event-registration/?ee=5" onclick="mixpanel.track_links("#aesml-i", "Click AESML Row 1 register link");return false;">Register Now</a> | <a href="http://website.com/contact-us/">Contact Us For Assistance</a></div>
    As you can tell, I'm attempting to track link clicks by calling the function.

    What am I doing wrong? Tks much!
    Last edited by Pullo; Mar 4, 2014 at 02:33. Reason: Added code tags
    Go increase web site traffic by using 27 proven strategies!

  2. #2
    Gre aus'm Pott gold trophysilver trophybronze trophy
    Pullo's Avatar
    Join Date
    Jun 2007
    Location
    Germany
    Posts
    5,941
    Mentioned
    215 Post(s)
    Tagged
    12 Thread(s)
    Hi,

    I have no experience of using this, but had a quick look at the docs and will see if I can help.

    As you can read, mixpanel.track_links has two required parameters:

    css_selector:string - A valid CSS selector that matches the link(s) you want to track, preferably an ID.
    event_name:string - The name of the event to send when a link is clicked. This can be anything you want, like "clicked header link" or "footer link click".

    Regarding the first parameter, might it be the case that you have to add the id to the anchor tag itself, as opposed to its parent div?

    You have:

    Code:
    <div id="aesml-i" align="center">
      <a href="http://website.com/event-registration/?ee=5" onclick="mixpanel.track_links("#aesml-i", "Click AESML Row 1 register link");return false;">Register Now</a> | 
      <a href="http://website.com/contact-us/">Contact Us For Assistance</a>
    </div>
    Might this be better:

    Code:
    <div align="center">
      <a href="http://website.com/event-registration/?ee=5" id="aesml-i" onclick="mixpanel.track_links("#aesml-i", "Click AESML Row 1 register link");return false;">Register Now</a> | 
      <a href="http://website.com/contact-us/">Contact Us For Assistance</a>
    </div>
    Admittedly, this is a bit of a shot in the dark.


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •