function DNA(str_account) { this.str_account = str_account; this.arr_data = new Array(); } DNA.prototype = { track: function() { this.gather_basics(); this.gather_transactional(); this.send(); }, goal: function(str_name) { this.add_data('g', str_name); }, gather_basics: function() { this.add_data('r', (document.referrer ? document.referrer : 'unknown')); this.add_data('c', (document.cookie ? document.cookie : 'unknown')); }, gather_transactional: function() { // Check if it has been defined already before... if ((typeof this.arr_data['tv']) == 'undefined') { this.add_data('tv', (((typeof _dna_trans_val) != 'undefined') ? _dna_trans_val : 'unknown')); } if ((typeof this.arr_data['tr']) == 'undefined') { this.add_data('tr', (((typeof _dna_trans_ref) != 'undefined') ? _dna_trans_ref : 'unknown')); } }, trans_val: function(mix_val) { this.add_data('tv', mix_val); }, trans_ref: function(str_ref) { this.add_data('tr', str_ref); }, add_data: function(str_field, mix_val) { this.arr_data[str_field] = mix_val; }, send: function() { var str_url = '?a='+this.str_account; for (str_field in this.arr_data) { // Ignore functions in Array if ((typeof this.arr_data[str_field]) != 'function') { str_url += '&'+str_field+'='+this.encode(this.arr_data[str_field]); } } document.write(''); }, /** * Compatible string-encode */ encode: function(str_val) { if(encodeURIComponent instanceof Function) { return encodeURIComponent(str_val); } else { return escape(str_val); } } };