Support

Home Forums Event Espresso Premium facebook conversion

facebook conversion

Posted: September 7, 2014 at 4:26 am

Viewing 21 reply threads


brent verco

September 7, 2014 at 4:26 am

hi guys.

EE4 is running great on my wesbite

http://www.amsn.com.au so thanks for the hard work, great support and cleaner code.

I’m trying to install the facebook conversion code to the thankyou page of my enrollments so I can gauge the effectiveness of my facebook advertising.

facebook have provided some code ( looks to be php not html) that is to be placed ” Copy the code below and paste it between <head> and </head>

where can I place the code so that it tracks my thankyou page ?

how can ensure that future upgrades dont erase my hard work ?

anything else I should know ?


Dean

September 8, 2014 at 1:38 am

Hi,

“where can I place the code so that it tracks my thankyou page ?”

Generally anything that goes in the head tags, will go in the header.php of your theme.

Depending on the code type, some themes have options sections where you can add it (usually for JavaScript only) other wise you would need to edit the php template.

Placing something in the header.php means it will be on EVERY page, so be aware of that.

Looking at this, https://www.facebook.com/help/435189689870514/ it seems it is JavaScript.

“how can ensure that future upgrades dont erase my hard work ?”

If the template needs editing, use a child theme: http://codex.wordpress.org/Child_Themes

Otherwise if your theme supports an option to add code to the header, then it should be safe to simply use those (double check after an update though as I’ve had themes remove tracking codes before…).


brent verco

September 8, 2014 at 4:02 am

gday Dean,

hope you are well and the office is settling down after the EE4 transition.

Yes the link you found on facebook is the correct one I am trying to install the conversion script shown.

I understand that placing the code in the header.php will result in every page being tracked.

My intention is track only completed enrollments. This will allow me gauge accurately exactly how much my advertising results in actual enrollments as apposed to just website views.

I can also see how many click the link from facebook ads so there is not much point placing the code on every page.

I dont think my theme supports an add code to header option for one particular page although i’m not entirely sure how to tell.

Any further thoughts on how to achieve this goal ?

cheers mate
Brent


Dean

September 8, 2014 at 4:37 am

Hi Brent,

If the theme doesn’t support an option for it then you will have to add the script directly to the header.php, either in the theme (updates to the theme WILL over write this) or via a child theme.

You could try using a Page Template, and you could duplicate the header and call that secondary header via the page template, that way only the pages with the special header would be affected.

Again, that’s best performed via a Child Theme

More info on custom headers http://codex.wordpress.org/Function_Reference/get_header


brent verco

September 9, 2014 at 4:22 am

I dont think I will wory about child theme as i wont be updgrading theme to see.

I found this code that looks like it might call different version of the header from the main template. here is the code shown on the link you sent through regarding custom headers.

http://take.ms/SS6QA

I have created a file Header-2.php and uploaded to the theme directory in the same location as header.php. Its exactly the same in content as the header file but has the conversion java script just before the /head part of the file as per facebooks suggestions.

I am trying to write header code at the top of the page.php file that will call header-2.php in the event that the page name is Thank You and then the deafault header for any other page.

Q1) Do I use the ” Thank You ” as the page name to call or do I use the slug ” thank-you ”

the code I am considering to try is

<?php
if ( is_thank you() ) :
get_header( ‘header-2’ );
else :
get_header();
endif;
?>

Do you think thats worth a shot or have I missed something.

sorry to be slightly of topic, please feel free to ignore if your snowed under ๐Ÿ™‚


Dean

September 9, 2014 at 4:27 am

Hi,

http://codex.wordpress.org/Function_Reference/is_page is what you need.

Personally I would simply make a page template and assign it to that page, and use the get_header() instead, but it’s your call.


brent verco

September 9, 2014 at 5:27 am

Ok I have taken your advice

ha must be so close.

1. I made a page template shown here
https://monosnap.com/image/svahuFs57hBCFELkNOUFgLE0cxhaU3#

and a header.thankyou.php file which is an exact copy of my head.php with the tracking code script added.

both these files have been ftp’d to the theme directory
https://monosnap.com/image/mXA9EquGI0BT9DB5gwJveZfLoJiPsF#

yet when i select the thankyou as a template the checkout page fails to load.
https://monosnap.com/image/M8QVMghhMPrJBZ5mww5vadDEBQMZO2#

I have re-instated the default page template so my site does not crash.

I suspect i have not quite got the code right to call the thankyou version of header.

if there is anything obvious you can see would love ya !


brent verco

September 9, 2014 at 5:29 am

oh yes in case it helps this was the original page.php that I attempted to create the new page template from

https://monosnap.com/image/LTB5SSh4cYT9dnjfQUceTfb43o0vrn#


Dean

September 9, 2014 at 5:54 am

Try header-thankyou.php not header.thankyou.php


brent verco

September 11, 2014 at 2:30 am

sorry that was a mistake in this post.

the file name and call to in the php is actually header-thankyou.php

I think I might leave this im getting out of my skill zone again unless there is something else obvious I missed ?


Lorenzo Orlando Caum

  • Support Staff

September 11, 2014 at 2:45 am

Hi,

I looked through your feedback. What happens if someone browses directly to the thank you page?

I think that will fire the conversion pixel.


Lorenzo


brent verco

September 11, 2014 at 2:54 am

HI Lorenzo

thanks for the the suggestion.

steps I just tried
1. re-enabled the thankyou template
2. attempted to navigate directly to the page as per your suggestion
3. The page failed to load.
4. I re-activeted the default template to keep my site functioning

mmmmmm

tricky little rascal isnt it !


Lorenzo Orlando Caum

  • Support Staff

September 11, 2014 at 4:21 am

Hi,

That was more of a question on reporting. If its added to the header for the thank you page, then it will fire whenever that page is loaded which could skew your conversion rate.

Can you upload the files that you are editing to something like pastebin and then link to them here?


Lorenzo


brent verco

September 13, 2014 at 4:32 am

HI Lorenzo,

sorry for the misunderstanding. Now I understand your point.

still I think its still the best option to try and get an understanding of the conversion rate.

I think the easiest option would be to give you the wordpress login and ftp details.

i will send them in a seperate email to support

thanks for the reply Lorenzo hope you had a great weekend


Lorenzo Orlando Caum

  • Support Staff

September 13, 2014 at 1:44 pm

The login information did not work but here is another way to accomplish this.

There is a WordPress conditional that can test for a particular page:

is_page()

The thank you page for Event Espresso is a WordPress page so it has a numeric id assigned to it. You can find it in the URL while viewing that page in the page editor within your WordPress dashboard.

See this tutorial:

https://gist.github.com/lorenzocaum/307016676842e4f5c456


Lorenzo


brent verco

September 14, 2014 at 3:29 am

Hi Lorenzo,

I double checked the credentials and at first they did not work either. interesly when I typed the ftp password in manually instead of cut and pasting it worked fine. thats weird !

I looked up the page number, its 1764.

I like your idea of modifying the header with the is_page conditional code.

what Im still confused on is the java script.

Do I create a file with the javacript in it in my wordpress uploads folder and then link to it or do I literally past the javascript code directly between the tags

sorry for the confusion thanks for your persistence ๐Ÿ™‚


Lorenzo Orlando Caum

  • Support Staff

September 14, 2014 at 4:04 pm

Replace the sample JavaScript with your JavaScript.


Lorenzo


brent verco

September 14, 2014 at 8:00 pm

I was planning on adding the following code just before the /head tags in the header.php file

https://monosnap.com/image/6i3d0HdkyoKSKvByUllbolLagit1xm#

I just cut and pasted the suggested code from facebook and used the if page call that you suggested.

I know its hard to tell by just looking at but is this worth a try in the current format ?


brent verco

September 14, 2014 at 8:03 pm

I just noticed 2 arrows on line 2 of the text in the code above just left of the facebook line. that looks wrong to me I guess I should delete one


Dean

September 15, 2014 at 2:08 am

Hi,

Now that EE 4.4.0 is released, you might be able to use the following hooks:

AHEE__thank_you_page_overview_template__content
AHEE__thank_you_page_overview_template__bottom

They don’t add it to the head, but they are specific to the thank you page.


brent verco

September 21, 2014 at 5:26 pm

Ha so many ways to skin a cat.
I dont really understand that Dean. Im sorry.

I think I might stick to Lorenzo’s method. Does the code placement that I posted 2 posts above look ok ?


Lorenzo Orlando Caum

  • Support Staff

September 22, 2014 at 9:39 am

Remove the extra angle brackets. There is one at the beginning where the comment is for Facebook and one at the end after noscript.


Lorenzo

Viewing 21 reply threads

The support post ‘facebook conversion’ is closed to new replies.

Have a question about this support post? Create a new support post in our support forums and include a link to this existing support post so we can help you.

Event Espresso