Hi,

I'd like to set up some conversion tracking (via google) for our drupal site.

my first thought was to create a custom block,
& paste the required javascript provided by google into the code block with "full html" input mode on,
and only allow the block to display on a specific page ( eg. cart/checkout ) .

The selective display works,
and the javascript is showing up on the source for the target page,
but google is saying
"The conversion tracking code could not be found on the specified website. Please make sure that you entered the correct URL, and that the code was copied in its entirety."

I've tried placing the code in the header,left block,footer without any improvement.

So I guess it is time to crack open the analytics module ( a working example of how
google likes to tango) but I'm also open to any suggestions about alternative approaches.

Comments

TiViTi’s picture

im also interested in this.
i just wanna track, visitors come from google adowrds going to be a member or not.

hello12345’s picture

The way I did it is...since I wanted to track all of my pages, I did a php include to an html file in my theme page.tpl.php file. The html included has the google analytics tracking code. If I do a view source on all of my pages, it now has the google tracking code.

TiViTi’s picture

yurg’s picture

Google Analytics Installation guide says: "place our code _right before closing _ tag". And I'm fully agree with hello12345: the one and only way to make google analytics work is to place it's code directly in page.tpl.php of your theme, right before tag. All other methods will lead to incorrect results. I've tested it at >5 sites.

If you want to track somthing special (cart/checkout effectiveness) you need to use Google's "target" analysis. All info also avaliable in Google Analytics docs. Define targets let you track different parts of your site more precisely.

clm23’s picture

well, I believe the problem was the input filter
inserting line breaks.

here's the other thread
http://drupal.org/node/146580

now I can create blocks,
c&p javascript from google,
and stick them only on certain pages

and best of all, it seems to work . .

xamenek’s picture

I did some poking around after reading this and found that there's a Google Analytics module already available. Just download it:

http://drupal.org/project/google_analytics

-Install it to your modules directory
-enable it at Admin>>Site Building>>Modules
-link it up with your Google Tracking ID at Admin>>Site Configuration>>Google Analytics

Good luck!

-----------
http://softwaretiger.com

Peculiar_One’s picture

I've installed the Google Analytics module, enabled it and entered my Google provided ID as well as verified that my theme has the $closure tag as per the documentation, but Google is still saying "tracking not installed"? Any ideas? (Running 5.5)

Peculiar_One’s picture

Sorry folks--didn't realize where I was posting last night. I see now this is module development; not support. Will try to remember to 'look before I leap' in the future...again, my apologies.

JJacobsson’s picture

Yeah I had the same problem. Google Analythics failed to verify the tracking code. What I had to do was disable local chacing of the urchin.js, go to google and verify it (worked, yay!) and then I re-eenabled local caching of urchin.js and it kept on working.

Peculiar_One’s picture

It's working now (see this post), but I don't know how or why. I was just looking to see what the default cache setting was; couldn't find it and thought maybe I had seen it at Google so I logged in and clicked on 'Edit Analytics Account' and discovered something interesting.

Somehow, and I don't know how because I didn't do it, there was a second, unnamed account created. I only noticed this because I distinctly recall setting my time zone (EST) and at first glance I saw GMT and thought it was set wrong. It might have read "(GMT-05:00) Eastern Time" all along, but not paying much attention, I set it to Eastern Time again and hit the save changes button. Google gave me an error message because the account name field was empty. Still not really thinking much of it, I proceeded to enter in an account name. That's when I began to get suspicious and started looking around a little more. I discovered that Google is still not accessing the script from the original account, which I would expect to be the module as that's what I tried first--yet if I disable it, the code ceases to exist when I view source. How and/or what created a second account that works is a complete mystery to me. Guess I'll have to contact Google, have them delete both accounts and start over from square one.

Oh, and I found the cache setting I was looking for; the urchin.js wasn't being cached locally (which is the default setting). But thanks again for the response just the same--I appreciate it. :)

userofdrupal’s picture

I had this problem and I couldn't figure it out. I went to www.example.com/admin/settings/performance and turned of caching and then checked my GA "check status" and now it says it's installed.

edlingx’s picture

I have the same problem, When i look at the sourcecode i find that drupal has added some p tags in the Google script. I guess that this is what messes things up.

vvchik’s picture

U have to make new block
with php code some like this

echo'
google code here
....
'

' is nessesary!

decibel.places’s picture

If you are using a rich text editor (FCKeditor et al) it will add <p> tags

you need to switch to source editing without the rich text

I generally exclude all the code textareas from displaying the FCKeditor

on another note, I have been successful tracking on site conversions with webforms

~are you netsperienced? /\_][_][_/\ Reliable Web Hosting - cheap!

gabash’s picture

did you put some kind of code on the confirmation message in the configuration page of webform?
if you did what was the code please?
Thanx

decibel.places’s picture

We are currently running 4 or 5 campaigns, using multisites to create microsites with their own themes and tracking.

I did a few things:

I put php and javascript code in the body of the webform and landing pages to capture the referrer and set a session cookie with the information; the goal is to track 1) the first landing page 2) the referring page before the webform

I use hidden fields in the webform for the referrer and the landing page stored in the session cookie.

In webform additional processing I am sending a custom email to a dealer determined by the zipcode entered by the user, as well as an email to the user; our analyst receives the regular webform email that also contains the hidden fields with the referrer and landing page info.

I am using the webform reports module to view the individual and aggregated webform data

GA also helps track the conversions

In some cases I am also displaying the dealer info (determined by user zip code) in the confirmation page.

The dealer info is stored in a table imported into the database from csv.

betancourt’s picture

Paste the code in the "Confirmation message" field, this way you will just track the conversion if the visitor sends the form and not just loading the webform page. Remember to select the Full HTML filter.

Cheers

thepocketgeek’s picture

I tried doing that but ended up with /* */ appearing on the confirmation page. Is that normal or are there special tags that are needed to wrap the code block in?

betancourt’s picture

Just remove the comments from your code or check the configuration for your input filters to enable comments.