Browse Source

Added exclusion capabilities

bmallred 12 years ago
parent
commit
ffa8f923ef
2 changed files with 6 additions and 4 deletions
  1. 1 0
      example.html
  2. 5 4
      jquery-analytics.js

+ 1 - 0
example.html

10
		<li><a href="#NoMetatdata">No metadata</a></li>
10
		<li><a href="#NoMetatdata">No metadata</a></li>
11
		<li><a href="#AssignedId" id="staticId">Assigned identification</a></li>
11
		<li><a href="#AssignedId" id="staticId">Assigned identification</a></li>
12
		<li><a href="#DefaultMetadata" data-analytics-dog="terrier">Default metadata given</a></li>
12
		<li><a href="#DefaultMetadata" data-analytics-dog="terrier">Default metadata given</a></li>
13
		<li><a href="#Excluded" class="analytics-exclude">Excluded link</a></li>
13
	</ul>
14
	</ul>
14
15
15
	<p>These links have been dynamically created at runtime but still are being traced.</p>
16
	<p>These links have been dynamically created at runtime but still are being traced.</p>

+ 5 - 4
jquery-analytics.js

1
// The MIT License (MIT)
1
// The MIT License (MIT)
2
//
2
//
3
// Copyright (c) <year> <copyright holders>
3
// Copyright (c) 2013 Bryan Allred <bryan.allred@gmail.com>
4
//
4
//
5
// Permission is hereby granted, free of charge, to any person obtaining a copy
5
// Permission is hereby granted, free of charge, to any person obtaining a copy
6
// of this software and associated documentation files (the "Software"), to deal
6
// of this software and associated documentation files (the "Software"), to deal
58
    var settings = {
58
    var settings = {
59
        attributes: [],
59
        attributes: [],
60
        assignTo: ["a", "input[type='submit']"],
60
        assignTo: ["a", "input[type='submit']"],
61
        url: null,
62
        client: null
61
        client: null,
62
        exclude: ".analytics-exclude",
63
        url: null
63
    };
64
    };
64
65
65
    // Walk the tree of a given node.
66
    // Walk the tree of a given node.
97
        // Locally scope this variable.
98
        // Locally scope this variable.
98
        $this = $(this);
99
        $this = $(this);
99
100
100
        if (settings.url && !$this.is(".analytics-captured")) {
101
        if (settings.url && !$this.is(".analytics-captured") && !$this.is(settings.exclude)) {
101
            // // We prevent the default action to allow the background call to succeed.
102
            // // We prevent the default action to allow the background call to succeed.
102
            // e.preventDefault();
103
            // e.preventDefault();
103
104