Posted: 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 ? |
|
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…). |
|
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 |
|
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 |
|
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. 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 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 ๐ |
|
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. |
|
Ok I have taken your advice ha must be so close. 1. I made a page template shown here 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 yet when i select the thankyou as a template the checkout page fails to load. 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 ! |
|
oh yes in case it helps this was the original page.php that I attempted to create the new page template from |
|
Try header-thankyou.php not header.thankyou.php |
|
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 ? |
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. — |
|
|
HI Lorenzo thanks for the the suggestion. steps I just tried mmmmmm tricky little rascal isnt it ! |
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? — |
|
|
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 |
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 — |
|
|
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 ๐ |
Replace the sample JavaScript with your JavaScript. — |
|
|
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 ? |
|
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 |
|
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 They don’t add it to the head, but they are specific to the thank you page. |
|
Ha so many ways to skin a cat. I think I might stick to Lorenzo’s method. Does the code placement that I posted 2 posts above look ok ? |
Remove the extra angle brackets. There is one at the beginning where the comment is for Facebook and one at the end after noscript. — |
|
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.