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've moved the forum!

Please use forum.silverstripe.org for any new questions (announcement).
The forum archive will stick around, but will be read only.

You can also use our Slack channel or StackOverflow to ask for help.
Check out our community overview for more options to contribute.

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

Using Google Conversion Tracking Code


Go to End


8 Posts   7933 Views

Avatar
Susie

Community Member, 3 Posts

25 August 2009 at 10:13am

I'm trying to insert Google Conversion tracking code into my website. I already have Google Analytics tracking code installed and working, on all pages. See this article for the difference between the two https://adwords.google.com/support/aw/bin/answer.py?answer=55535&cbid=-gii343izfz9n&src=cb&lev=answer
Conversion code needs to be installed on each page where a conversion occurs - like the Thank You page for a purchase or newsletter sign up. And Google specifically says:

First, choose a page that users reach when an action you consider to be desirable has been completed. For example, this might be the 'Thank you for your purchase/download/subscription' page, which a user reaches after they've finished a transaction. This is the conversion page, where you should place the conversion tracking code snippet. The code should be placed between the <body> and </body> tags, in a valid HTML location. It should not be between the < and > of any other tag. Usually, the tag is placed towards the bottom of the web page, since this will be the location of the Google Site Stats text block which will be visible to users who see this page after viewing a Google ad.
None of my pages have body tags in SilverStripe. I guess it's in a template file. When I try to insert the conversion code inside body tags, the script shows up and the tracking object does not.

I've searched these forums for help with where/how to place this code, and I found this one reference:
http://silverstripe.org/archive/show/83408#post83408
one simple solution might be, hacking your page.ss file
<% if MenuTitle = "yourthankspageMenueTitle" %>
... here comes your AdWordsCode ...
<% end_if %>

Is this still the way to do this? This answer was for someone who wanted to place the conversion code on one page only, and I would like to install this code on several pages, not just one. I could just keep writing that code, with different page titles, I guess. Seems inelegant somehow...
Thanks so much,
Susan

Avatar
dalesaurus

Community Member, 283 Posts

27 August 2009 at 9:29am

Well there is no baked in functionality to do this, and adjusting your template will be an all or nothing addition.

To do this selectively I would think of the following:

1. Modify your Page.php and add a Varchar for "GoogleConversionCode" and the appropriate entry box for it
2. Create a function (that acts as a control) to return just that "GoogleConversionCode" variable data
3. Add that control to your Page.ss
4. Edit any of the pages you want the Google Conversion code and place the code in the Page's CMS entry box you created in #1

This is with different goals/conversions, if you only have 1 piece of code you could use a boolean and and include. Might be an easier way...I have a habit of over complicating things.

Avatar
dhensby

Community Member, 253 Posts

27 August 2009 at 11:13am

Hi Susie,

This is a good question and i have been thinking long and hard about similar things. I want to build a really comprehensive Google Analytics module but i dont have the time at the moment and it is a big job.

Because forms can have a 'finished' URL (eg: example.com/contact-us/finished) [URLS are split like: domain/$page/$action/$id/.../ that you can do something along the lines of:

<% if Action = success %>
[google code]
<% end_if %>

This assumes that you send users to a /$page/success page of course.

$Action or Action may have to be defined in the Page class, i'm not sure if you can access it directly through the templating language.

Avatar
Susie

Community Member, 3 Posts

27 August 2009 at 11:32am

Thanks to both of you, Pigeon and Dalesaurus. I get what you're saying, but I'm not a web programmer at all. More like an attempter! I know how to edit html a bit, but not like what you both are describing, although as I said, I can hang with the conversation, I understand the vocabulary. Well, I will see what I can do, but SS programmers should know that inserting Google Analytic and Conversion is what it's all about, in terms of ROI for websites. I'm a sole prop tech support biz, and clicks are one big way to reach my customers, since I've defined a small geographic area for my ads. If/when someone creates a module for inserting this code into different pages, I can use it and sell it - it's would make Google AdWords totally accessible via SS to anyone with a website that drives business to them. I don't think anyone else can combine the easiness of SS with Google Adwords, for such a low cost, I mean. I could then use SS and Google Adwords with other clients, another biz for me.
Keep up the great work!
Susie from Philly

Avatar
dhensby

Community Member, 253 Posts

27 August 2009 at 12:06pm

Hi susie,

I dont see this being a hugely technically challenging solution to your issue. Is there any part you are not sure about? Do you have a live site i can nosey around to give you a better suggestion?

How well do you know the back end of the site? Basically, whenever a 'goal' is reached, or a conversion happens, you would expect the CMS to create or write an item to the database, eg: creating a new user, a new order, a form submission. You would know when this happened and would be able to write an include of some sort or way of deducing that it was the correct page to insert the tracking code to.

Avatar
edi2lopez

Community Member, 6 Posts

14 October 2009 at 10:39am

Is it possible to use User Forms [v0.2.0] Module with Google tracking code? For example: CanI insert the Google conversion code in the "On complete" tab of the module? Any help will be appreciated. Thank you

Avatar
edi2lopez

Community Member, 6 Posts

31 October 2009 at 7:44am

It is working fine on my site, this is how I did it. I just added the Google conversion tracking code (Adwords) at the end of the ReceivedFormSubmission.ss file. This file is in the User Forms Module. (location: /userforms/templates)

Avatar
edwardlewis

Community Member, 33 Posts

11 April 2011 at 10:09pm


I just wrote a blog post on how to add the conversion tracking code..

http://blog.assembleonline.co.uk/2011/04/11/adwords-conversion-tracking-silverstripe-userforms/

Should be easy if you follow that :)