Viewer problems with Google tracking codes

19 posts by 6 authors in: Forums > CMS Builder
Last Post: July 26, 2010   (RSS)

I've noticed a problem this morning where a customer sent out a e-mailshot with Google tracking code appended to the URLs in the email. The problem occurred because one of the URLs in the email linked to a CMS Builder controlled page with the viewer code being as follows:

list($servicesRecords, $servicesMetaData) = getRecords(array(
'tableName' => 'services',
'where' => whereRecordNumberInUrl(1),
'limit' => '1',
));
$servicesRecord = @$servicesRecords[0]; // get first record

Using the link in the email to the page showed a 'Record not found' message which turned out to be because the whereRecordNumberInUrl(1) function was extracting the number from the tracking code.

The tracking code in the URL was like this portfolio.php?utm_source=Newsletter&utm_campaign=61e077629-20101_28_2010&utm_medium=email

I fixed it on this occassion by adding some code in place of whereRecordNumberInUrl(1) to check for the request variable utm_source, but wondered if there was a way this could be built into the product in future in any way?

Thanks, Paul.

Re: [pothompson] Viewer problems with Google tracking codes

By Dave - February 3, 2010

Hi Paul,

For single section viewers, you can just remove this line:
'where' => whereRecordNumberInUrl(1),

For multi record viewers such as: portfolio.php?project-123 do you think we should just strip out utm_* values from the url when determining the record num? Are there any other utm_ fields that are commonly used that we'd need to look for?
Dave Edis - Senior Developer
interactivetools.com

Re: [Dave] Viewer problems with Google tracking codes

Hi Dave,

Looking around, Google use five parameters in their tracking URLs, you can see them listed here http://www.google.com/support/googleanalytics/bin/answer.py?answer=55578

I guess ignoring these in the query string wouldn't be a bad idea in any case, but there's always scope for other variables to be added to the URL, if for example they're from Yahoo Pay Per Click or anywhere else that appends tracking data. I don't think they all use utm_ as a prefix but at least by ignoring these you've probably covered 95% of situtations.

The other option I had thought of was possibly adding an additional parameter to the getRecords() function to always return a record. Say 'neverBlank' => '1', so even if a record number is extracted from the URL but no records match that number, then the first one is returned anyway.

The situation I have is the page portfolio.php can be called without any parameters in which case it returns the first record as per the sorting defined, or can be called with a record number a loads the specific record. I know that it's never going to be called with an invalid record number and if it is, either because somebody manually types the URL, or because the URL has some tracking code appended, then showing the first record would be better than showing no record.

Thanks, Paul.

Re: [pothompson] Viewer problems with Google tracking codes

By Dave - February 3, 2010

Hi Paul,

>The other option I had thought of was possibly adding an
>additional parameter to the getRecords() function to
>always return a record.

That's actually what the argument in this line does:
'where' => whereRecordNumberInUrl(1),

So if there's no number on the end of the url it uses that value as the where. So you get "WHERE 1", which is always "true" and should return everything. I'd be curious why that didn't work on that page.

Another option for numbered pages would be to remove the where line and use ?num=123, as that will filter on the record number and adding extra values to the url won't change anything.

Hmm, I'll give this one some more thought.
Dave Edis - Senior Developer
interactivetools.com

Re: [Dave] Viewer problems with Google tracking codes

By jarvis - May 20, 2010 - edited: May 20, 2010

Good Morning,

Did anything more come of this? I too am having the same issue. My page link is services.php but as soon as you come through from a mail campaign the URL changes to:

services.php?utm_medium=email&utm_source=Emailmarketingsoftware&utm_content=588672023&utm_campaign=Issue2-May2010


I tried the code mentioned above, however, as services is a section, removing that line means you can't view the sub pages.

I hope that makes sense? I've therefore put that line back in and de-activated Google Analytics from the mail campaign until I can resolve it.

I also found this thread:
http://www.interactivetools.com/iforum/Products_C2/CMS_Builder_F35/gforum.cgi?post=73021;search_string=analytics;t=search_engine#73021 Unfortunately, this won't work for me either as my services page doesn't go to services details, mine works like so:
services.php?Media-Training-14

Any feedback/ thoughts on this would be great.

Many thanks,

jarvis

Re: [jarvis] Viewer problems with Google tracking codes

By Jason - May 20, 2010

Hi Jarvis,

From the url you posted, it looks like all of the variables in the query string are related to a mail campaign.

In services.php, are you trying to do any sort of search? Is the table for services.php a single or a multi-record section?

Let me know and we'll find a solution.

Thanks
---------------------------------------------------
Jason Sauchuk - Project Manager
interactivetools.com

Hire me! Save time by getting our experts to help with your project.
http://www.interactivetools.com/consulting/

Re: [Jason] Viewer problems with Google tracking codes

By jarvis - May 20, 2010

Hi Jason,
Thanks for the reply, I believe Damon is looking into this for me now as he has the details. If he finds a solution, I'll update this thread unless Damon does in order to help others.

Many thanks,

Jarvis

Re: [Dave] Viewer problems with Google tracking codes

By jarvis - May 20, 2010

Hi Dave,

It's version 2.01 if that helps?

Thanks

Re: [jarvis] Viewer problems with Google tracking codes

By Dave - May 20, 2010

This was added in 2.03:

- Viewers: whereRecordNumberInUrl() now ignore campaign tracking utm_* values when determining record number
Dave Edis - Senior Developer
interactivetools.com