Skip to main content

This site requires you to update your browser. Your browsing experience maybe affected by not having the most up to date version.

We're retiring the forums!

The SilverStripe forums have passed their heyday. They'll stick around, but will be read only. We'd encourage you to get involved in the community via the following channels instead:

General Questions /

General questions about getting started with SilverStripe that don't fit in any of the categories above.

Moderators: martimiz, Sean, Ed, biapar, Willr, Ingo, swaiba

Google adwords tracking and Silverstripe

Go to End

9 Posts   2736 Views


Community Member, 224 Posts

24 October 2009 at 9:20am

Edited: 24/10/2009 9:21am

I have been fighting this for days. I have tried the meta tag because I didn't think SS excepted /?t=tracking codes on the end of the url. So I was trying the custom meta tag, in both cases, it works fine on a standard .php page, but not in Silverstripe.

Any ideas of how anyone else is grabbing the tracking code from google adwords campaign when using SS as a landing page???


Community Member, 283 Posts

24 October 2009 at 10:07am

You'll have to do some custom coding for this. Probably in the init() of Page_Controller for all pages, or the specific action if you are working with a particular one.

You can grab t like so:

if( $tracking = $this->request->getVar('t') ) {
  // Do something with $tracking


Community Member, 224 Posts

24 October 2009 at 1:19pm

Edited: 24/10/2009 1:21pm

Thank you. I am ready to try anything. I have not messed with the code of the CMS much so if you would please give me some direction. Where do I locate the init() of Page_Controller?

Ok, found this...


class LandingPagePpc extends Page {
static $db = array(
static $has_one = array(
static $icon = "landingpageppc/images/window";

class LandingPagePpc_Controller extends Page_Controller {
function init() {



Would I add your if statement in here?


Community Member, 224 Posts

24 October 2009 at 5:45pm

Edited: 24/10/2009 5:52pm

I have exhausted everything. Is there any one out there that can help me with what dalesaurus has proposed? This is the best solution I am sure.

Are there SS programmers?

This all works fine on a stand alone page, somehow SS removes the tracking code.

This is my stand alone page... I am getting the meta content and passing it into the form. I want to use the SS custom meta field to enter my custom meta tracking code for this page. Then I can use one form to get the different tracking codes per page. When I hard code it like in this page it works fine. When I add this code to my .ss file everything passes to the next page, but the tracking code. I do not understand classes, but maybe someone can help me with the answer here.

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "">
<html xmlns="">
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<meta name="tracking" content="mycode" />


<!--<script language="JavaScript" type="text/javascript" src=""></script>-->
<table width="100%" border="0" align="center" cellpadding="0" cellspacing="0" >
<td width="400">
<table width="100%" height="300" border="0" cellpadding="0" cellspacing="20" style="background-color:#FAF8E4; border:#999999 dashed 1px;">
<td colspan="3"><h1 align="center">Entrepreneurs Wanted</h1>
<p align="center">There is an entrepreneur in all of us. Come join us and learn how to unlock yours. Let&rsquo;s do this together! </p>
<p align="center">We're global, though <b>United States</b> is one of our key growth areas right now!</p></td>
<td><img src="../../../themes/site/images/blank.gif" width="50" height="1"></td>
<td><form method="post" action="" target="_top"><input type="hidden" name="unit" value="sne_ccp_leads">
<input type="hidden" name="custom Url" value="">
<input type="hidden" name="redirect" value=""> <!--HANDLES LEADS & REDIRECTS-->
<input type="hidden" name="meta_redirect_onlist" value="">

<script language="JavaScript" type="text/javascript">
function getTracking() {
var metas = document.getElementsByTagName('meta');
var i;
for (i = 0; i < metas.length; i++)
if (metas.getAttribute('name') == "tracking")
var getVar = metas.getAttribute('content');
return getVar;


var t = getTracking();
//var t = "";
//if(urlquery[1]) {
// urlterms=urlquery[1].split("&");
// t = urlterms[0];
document.writeln('<INPUT TYPE="hidden" name="meta_adtracking" value="', t, '">');
document.writeln('<INPUT TYPE="hidden" name="custom t" value="', t, '">');

document.write('<scr'+'ipt language="JavaScript" src="'+t+'"></scr'+'ipt>');
document.write('<scr'+'ipt language="JavaScript">\ndocument.writeln(\'<INPUT TYPE="hidden" name="custom Tracking" value="?v=\'+visit_id+\'">\');document.writeln(\'<INPUT TYPE="hidden" name="custom v" value="\'+visit_id+\'">\');\n</scr'+'ipt>');
<input type="hidden" name="custom member_id" value="10113">
<input type="hidden" name="custom landingpage" value="Custom">
<input type="hidden" name="meta_message" value="1">
<input type="hidden" name="meta_required" value="name,from">
<input type="hidden" name="meta_forward_vars" value="1">
<!--<input type="hidden" name="meta_adtracking" id="meta_adtracking" value="">-->

<table width="266" align=center>
<tr><td align=right><font color="green"><b>First Name:</b></font></td><td>
<input type="text" name="name" value="" size="20"></td></tr>
<tr><td align=right><font color="green"><b>Email:</b></font></td><td>
<input type="text" name="from" value="" size="20"></td></tr>
<tr><td align=right><font color="green"><b>Phone</b> (optional):</font></td><td>
<input type="text" name="phone" value="" size="20"></td></tr>
<tr><td align="center" colspan="2"><div align="center">
<input type="submit" name="submit" value="Submit">
<!--END FORM CODE --></td>
<td><img src="../../../themes/site/images/blank.gif" width="50" height="1"></td>
<td colspan="3"><p align="center"> Don't worry, you will be able to UNSUBSCRIBE at any time! </p>
<p align="center"> <a href="privacy-policy/" target="_blank">Privacy Assured</a>: Your email address is never shared with anyone. </p>

<p align="center"><strong>Fill out the form above to learn more about our mission to create <br>
100 millionaires by 2012.</strong></p></td>
</table> </td>



Community Member, 244 Posts

24 October 2009 at 8:29pm

I can spot a stack of logic and programming errors, as well as general implementation problems just by looking at the code quickly. For example:

for (i = 0; i < metas.length; i++)
if (metas.getAttribute('name') == "tracking")

doesn't actually perform any sort of loop. I would recommend that you spend time learning how to solve your own problems and how to program so you can spot and fix issues like these.


Community Member, 224 Posts

25 October 2009 at 3:38am

Edited: 26/10/2009 7:56am

I'm sure people like me upset true programmers, but I am 47 now, started programming a CAD program in AutoLISP, and other programming for the past years. I'm sick of it! That is why I asked to hire someone. No one seems to be available to program in SS on You seem to know where I am failing, yet are not offering me your services.


Community Member, 244 Posts

25 October 2009 at 11:25am

Edited: 25/10/2009 11:26am

I'm sorry if I came off sounding a bit snobbish or condescending , but to be honest it is difficult to program complex custom websites (that are reliable) without a significant investment in learning time.

To this end it sounds like your going in the right direction in trying to get someone else to contract out to. Since you're not having much luck with finding anyone on that freelance website, you might want to try the "Connect With Other SilverStripe Members" forum on this site. There's a few people advertising their services there. You might also have luck hiring the SilverStripe guys, or one of their official partners (which you can find on the company website). You could also hop on the IRC channel to see if anyone is available.

As for how to specifically fix that simple problem, the JS should probably read like (note I haven't tested this).

for (i = 0; i < metas.length; i++) {
	if(metas[ i ].getAttribute('name') == 'tracking') return metas[ i ].getAttribute('value');


Community Member, 224 Posts

26 October 2009 at 7:57am

Thank you Andrew, I appreciate your comments. I will take your advise into account and see who might be available.

Go to Top