/    Sign up×
Community /Pin to ProfileBookmark

Google Analytics tracking code while URL stays the same

I have a page with an inputform that is replaced by the thanks-text while the URL is staying the same. Therefore I can’t assign a URL to a conversion goal in Google Analytics. Because I only want to count conversions when the thanks-text has been shown.

In [URL=”http://support.google.com/googleanalytics/bin/answer.py?hl=en&answer=55521″]this Google document[/URL] I read that I have to call the following function:

[CODE]pageTracker._trackPageview(“/homepage/link1”);[/CODE]

So that’s very nice: I can create my own thanks-URL! But now my problem.

In a javascript-function I have the following code to fill out a div in the body:

[CODE]document.getElementById(“result”).innerHTML = str;[/CODE]

This is the div in the body

[CODE]<form name=”f1″>
<div id=”result”></div>
</form>[/CODE]

The string ‘str’ is made in another script that checks the validity of the forminput. In that script I know if the forminput is successful or not.

I can add the pageTracker code in the str, but then you get javascript in the innerHTML, which doesn’t work (I read elsewhere).

So how to solve this problem?

Thanks a lot!

to post a comment
JavaScript

1 Comments(s)

Copy linkTweet thisAlerts:
@nap0leonFeb 18.2012 — Confused... why can't you just invoke the function upon success?

<i>
</i>if (success) {
//whatever you do now
//pageTracker._trackPageview("/homepage/link1");
...


If that won't work... when you have success, create a 1pixel x 1pixel iframe that loads your thanks.html page that has "pageTracker._trackPageview("/homepage/link1");" in it.
×

Success!

Help @AlainS spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 6.15,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @nearjob,
tipped: article
amount: 1000 SATS,

tipper: @meenaratha,
tipped: article
amount: 1000 SATS,

tipper: @meenaratha,
tipped: article
amount: 1000 SATS,
)...