Google Analytics for Individual WordPress Pages [duplicate] - javascript

I'm trying to get Google Analytics Code to work on the thank-you page after customer has filled in the contact form and I've tried putting it in the thank-you page which is in the pages under admin in Wordpress backend using HTML tab but it seems to generate unnecessary p and br tags in between codes especially before closing tag. I'm not sure whether that is causing the issue or not.
Is there a way we can do this for just one page?

I'm not 100 % sure whether it's possible at all to insert javascript with the tinyMCE Editor of Wordpress.
If that's true, then you can try the following:
Get the posts' ID: Look at the linking in your admin menu when you are in the view where you can see all your posts, e.g.
http://www.your-url.com/wp-admin/post.php?post=796&action=edit
796 would be your ID here.
Enter the following in your header.php of your wordpress theme (to find at /wp-content/themes/theme-name):
.
<?php if (is_page(796)) { ?>
//YOUR ANALYTICS CODE IN HERE
<?php } ?>
Replace 796 with your ID here, and put your analytics code in between the PHP code.

It sounds like you're trying to add it using the "Visual" view, which formats whatever you put in into paragraphs, etc.
Try switching to "HTML" view (the tab is at the top right of the input box) and add it there - hopefully that should allow you to add it without converting it!
Edit: As per my comments below, I made a mistake - it seems even the HTML tab adds some degree of formatting.
In this case, you may find some use with this plugin:
http://wordpress.org/extend/plugins/raw-html/
This allows you to displable to auto formatting on a per-post basis. So on that specific page you could turn off the autoformatting simply to allow you to add that Analytics snippet.
The only other way I can think off offhand would be to write a custom page_template just for that thankyou page and add it to there. Instructions are here: http://codex.wordpress.org/Pages#Creating_Your_Own_Page_Templates

Related

adding remarketing code directly to link (link generator)

I have a following use case for the Retargeting link generator:
Add one or more retargeting codes directly to your link. When somebody clicks he will be automatically added to remarketing/retargeting list.
I'm going to code a script in JS on my domain which will do such thing.
Which steps should I make ? Maybe there is a Wordpress plugin or any other open source script that I didn't find.
I want something similar to this -> https://support.clickmeter.com/hc/en-us/articles/211032966-Retargeting-on-your-links
Please give me any advice :)
Solved :) - I've used Wordpress plugins:
- ACF Custom Fields
- ACF Code Field
then everything should be done on template page with $redirectURL and $scriptField :)

Adding Custom JavaScript into Individual Weebly product pages

I am trying to add an Age verification code to only certain categories on my Weebly store but can't figure out how to implement it on only certain pages. I tried adding an "Embedded element" to the pages but the script doesn't run. the code I am trying to get to work is:
'<script type="text/javascript" src="https://custom.ageverify.co/shopshag/av.js"></script>'
any help is appreciated!
An easy way to accomplish this is with the site http://age-verify.com. They provide the code snippet and there is a free plan.

JSP/Javascript: How to dynamically change a header based on the page im on

I have a header.jsp file that is included in all my pages on the website what acts as a template for all my header content (e.g site titles, logos, home links etc.). Inside this header.jsp I want to set up a page title in a h1 tag (for example) that would change to show the title of whatever page I am on when navigating through the pages of the website.
My initial thought was to use javascript to achieve this however based on the tutorials, most people are using frameworks like angular which I dont really want to resort to using unless there was no alternative. Is there any way I can change my headers to pick up whatever page I am on using raw JavaScript? Or, is there anything in jsp that can also make this possible? If so how can I achieve this?
How about setting the page title as a request attribute page_title and then fetching it in your header.jsp.
Thank you for the responses. I have managed to figure out one alternative that has worked for me though I wouldnt say it is the most graceful. (Any suggestions to improve this and I will update my answer for better understanding!) Also worth noting the solution was using jsp NOT javascript.
What I have done is within my header.jsp, I had set up in the body the following code between a div tag:
<%= subTitle %>
From there, I then applied the following code to all other pages on my website:
<% String subTitle="Example Page"; %>
'Example page' being the name of the webpage that I want to show on my header but it can be different on any page and had given me the expected results.
The only thing is however that in doing it this way, when it is set on Eclipse Luna I get a problem where 'subTitle cannot be resolved to a variable'. The code in itself works but it is problems like these that I would also rather resolve in order to provide the best solution. Any suggestions to remove this error would be appreciated.

Removing YOURLS branding from stat page

First off, here is my url: http://tini.link
So, basically, everything is going well. I have a completely custom homepage, with anti-spam and all that. Then a results page, with all sorts of special stuff. But, I want to customise the stats page.
I have worked out how to customise the admin pages. It's in includes/function-html.php. But if you customise the menus in there, they do not carry over to stats page.
Any ideas on where I can customise the stats page?
What I understand from the question is, you need this - http://www.php.net/manual/en/function.include.php
Create the menu in a separate PHP file and include that wherever you need the menu. Assuming your menu is in menu.php
In both includes/function-html.php and stats.php (assumption), wherever you need the menu, do something as follows.
<?php
...
//include menu here
include 'path/to/your/menu.php';
...
By doing this, you can customize menu.php and it will reflect everywhere you have included it.
NOTE - Let me know in comments if that's not what you are looking for.

manipulating tinymce in Wordpress

I need to be able to extract, manipulate and update the text in wordpress's tinymce #content textbox.The code is coded in a wordpress plugin.
The below post helps but i am unable to comment or contact the original creator to ask him further questions. Having 1 points I cant practically do anything except ask questions. Let me know if i am doing this wrong.
Basically the code from this link is what i need to manipulate or edit the content in wordpress tinymce editor.
Manipulating TinyMCE content with jQuery
But the code seems to be overly simplified.
so my question is:
Do i need to include jquery
Do i need to include the tinymce js or class? is it in wordpress itself?
The code seems to be half javascript half php? Is the code suppose to be coded in a .js file?
do i need to put php tags here?
// make it into a jQuery object
var $content = $(content);
// manipulate the jquery object using jquery
$content = $content.remove('a');
Thanks.
hi I have figured it out after a bit more researching.
At first I was working with php to manipulate data after it is saved. But then i went on to wanting to manipulate the text before it was saved like underlining certain text based on a list in the database. So I needed to move on to javascript because i was editing the text before it was submitted or a page reload which i didn't wrap my head around yet.
So next i just coded the changes into javascript and built a button to call the process.
and seems i didn't need to include the tinymce class because probably the header of the editor page has already included it.

Categories

Resources