Devam Ediyor

Google Analytics Custom Variable Code Fix

Hello All--

Our goal is twofold...

1. Scan a page for an area of text "ID" and then submit then place the number after said ID into a variable.

2. Pass the variable to Google Analytics.

The code we have is not working... it never finds the ID.

The script will be used on several pages, but the text to search for is always that same... that is:

ID: ## up to ID: #####

So the ID can be from 2 to 5 digits.

I'm attaching screenshots that visually display the example above.

The project shouldn't take more than an hour for the right coder. The broken/erroneous code is below:

(placed at the top of page)

<script type="text/javascript">

//Define a trim function to trim the white spaces both before and end of string

[url removed, login to view] = function () {

return [url removed, login to view](/^\s*/, "").replace(/\s*$/, "");}

//Search Function to get the ID

function GetID(){

var spans = $("span");

var i = 0;

//Define the regix object that checks the presence of both Applicant: and ID: in the string

var re = /Applicant:.+ID:.+/;

for(i = 0; i < [url removed, login to view]; ++i)

{ if( spans[i].[url removed, login to view](re))

{

return spans[i].[url removed, login to view]("ID:")[1].trim();

}

}

return "NOT FOUND";

}

</script>

(placed at bottom of page)

<script type="text/javascript">

var gaJsHost = (("https:" == [url removed, login to view]) ? "https://ssl." : "http://www.");

[url removed, login to view](unescape("%3Cscript src='" + gaJsHost + "[url removed, login to view]' type='text/javascript'%3E%3C/script%3E"));

</script>

<script type="text/javascript">

leadID = GetID();

try {

var pageTracker = _gat._getTracker("UA-1XXXXXX-1");

pageTracker._setDomainName("none");

pageTracker._setAllowLinker(true);

pageTracker._setCustomVar(1,"Lead_id",leadID,1);

pageTracker._setCustomVar(2,"Form_variation","CS",1);

pageTracker._trackPageview();

} catch(err) {}</script>

Beceriler: Google Analytics, Javascript

Daha fazlasını görün: fix google custom var, up string, text string search, submit prototype, string match, place code, our code, m string, match string, google js, get right code, get location javascript, get length string, define coder, code top, code get, custom write, type code, type scan, trim, take google, google place, google custom search, google code, ga search

İşveren Hakkında:
( 33 değerlendirme ) Raleigh, United States

Proje NO: #694825

Seçilen:

TakeReal

I can update your script to parse ID and it to Google Analytics.

1 gün içinde 40$ USD
(188 Değerlendirme)
5.8