Wordpress Sign-ups Using GA Goal Tracking - google-analytics

I'm trying to use GA Tracking to Track Wordpress Sign-ups on my site. I'm assuming I need to use Goal Tracking and NOT Event tracking for this. I tried setting up goal tracking but it's not working. I am not using any GA plugins like Yoast, etc.
I can't get this to work with Wordpress:
I set my Goal URL to: /wp-login.php?checkemail=registered (URL landing page for sign-ups)
Match Type: "Exact Match"
No Goal Funnel was set.
GA is not tracking any of my sign-ups. What I am doing wrong here? My site is www.StreetofWalls.com if you would like to test.

The script that loads google-analytics isn't on the login page, so you're not getting any of the /wp-login.php?checkemail=registered pageviews sent back to google.
Put this on your wp-login.php page
<script type='text/javascript' src='http://www.streetofwalls.com/wp-content/themes/sow3/js/google-analytics.js'></script>

While TomFuertes's answer will work, it is not good to modify core WordPress files like wp-login.php. Updates to WordPress will overwrite any changes that you make and avoiding WordPress updates is a very bad idea.
I recommend adding the code using the login_head hook in your functions.php file:
function add_ga_to_login_page(){
echo '<script>';
echo 'GA TRACKING CODE HERE';
echo '</script>';
}
add_action('login_head', 'add_ga_to_login_page');

Related

How to add a separate Analytics for each website page in Wordpress

We have a WordPress installation that has locations as separate pages.
For example: mysite.com/colorado and mysite.com/alabama
We need separate google analytics for each of these as well as 1 for all of mysite.com.
Is there a way to do this with a WordPress plugin(s) or will we need to hand code some things?
Thanks in advance!
If I'm not mistaken, Google Analytics lets you view your analytics in a breakdown like that. That said, if you do need individual scripts, it would be relatively easy to program in. There may be some plugins that do this, but I'm not aware of any in particular, though a cursory glance showed plugins like Header and Footer Scripts that allow you to add scripts on a page by page basis.
Some themes also allow you to add SEO/Script settings per page/post. If that's the case, you can just open up each page and dump each script tag in the "header scripts" or similar section, and call it good. (Genesis is an example of a theme that does this).
If not, programming this would be relatively straight forward. I'd do it something like this:
add_action( 'wp_head', 'display_analytics_by_page', 1 );
function display_analytics_by_page(){
// Default Script Code with individual UA codes replaced
$script = '<!-- Global site tag (gtag.js) - Google Analytics -->
<script async src="https://www.googletagmanager.com/gtag/js?id=[UA-CODE]"></script>
<script>
window.dataLayer = window.dataLayer || [];
function gtag(){dataLayer.push(arguments);}
gtag(\'js\', new Date());
gtag(\'config\', \'[UA-CODE]\');
</script>';
// Array of UA codes by state
$codes = array(
'Alabama' => 'UA-123456789-1',
'Oregon' => 'UA-987654542-3',
'Vermont' => 'UA-000000000-0'
);
// Get title of this page
$title = get_the_title();
// If this page title exists in the codes array, swap placeholder and echo it.
if( isset($codes[$title]) ){
echo str_replace( '[UA-CODE]', $codes[$title], $script );
}
}
I commented along the way, but the gist is to put in the "default" script, but pull out the UA code. This will only work if you need the same exact script code in each one, otherwise you'll have to add each script to the $codes array instead.
Then create an array of the UA Codes (or full scripts if needed), keyed by the page title.
Then check the page title, and if that exists, pull that code in and echo it. This is run on the wp_head hook, so you just need to put this code in your functions.php (or similar) file.
If you want to go easy with no-coding, then go with a plugin. Jump to Plugins > Add New and Search for Google Analytics in the search box. Install the plugin named Google Analytics for WordPress (Formerly GADWP). Activate and connect the plugin with your Google Analytics property. When all is done, you will see a new tab beside your post's title. See a screenshot here.
And if you want the net analytics for the whole web site then head to your admin dashboard. A new widget will appear there with the analytics.
Documentation for the plugin can be found here.
I hope it helps.
I'm curious why you need a separate GA account for all the locations? Common practice in this scenario would be:
Use 1 account
Create 1 GA view for the entire domain
Create +1 view for each location by filtering traffic based on the URL
If the different accounts are related to limiting user access, know that you can grant user access based on each property view.

Can I add my existing html homepage google analytics code into new wordpress homepage?

We are having a html website whose homepage and other few pages has google analytics code and keywords. Now we have created a new homepage on wordpress which will be our future homepage. So my question is can I use my existing homepage GA code into my new wordpress homepage? If yes then how? We don't want to lose our previous tracking data at any cost.
How can use it? Please Help.
TIA.
Yes, you can use your existing google analytics code by using WordPress plugins.
There are many plugins in WordPress which provides ability to integrate your google analytics code to your site and all pages dynamically and also display you a complete tracking reports as well.
here is one plugin link for your reference please check it.
https://wordpress.org/plugins/googleanalytics/
There are lot's of other plugins as well you can simply check out in WordPress plugins repository.
=> Also you can add your google analytics code programmatic as well.
Please copy below code and paste it into your activated themes functions.php file at the end of the file.
function add_google_analytics_code_to_pages(){
?>
<!-- Google Analytics -->
<script>
(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
})(window,document,'script','https://www.google-analytics.com/analytics.js','ga');
ga('create', 'UA-ADD YOU GOOGLE ANALYTICS ID HERE', 'auto');
ga('send', 'pageview');
</script>
<!-- End Google Analytics -->
<?php
}
add_action("wp_head","add_google_analytics_code_to_pages");
Just add your google analytics tracking id into about script.
Replace your tracking id instead of this code.
'UA-ADD YOU GOOGLE ANALYTICS ID HERE'
Unless I am missing something here, sure!
All you have to do is enter your Google Tracking code inside the <head> tags, within the header.php template file. Ideally, just before the closing </head> tag.
By inserting your Google Tracking code, within the header.php template file, every WordPress page will be tracked.
Your header.php template file will typically be found within the following directory path:
wp-content > themes > theme-name
If you are not the theme author, don't forget to create a Child Theme. You will then need to insert the appropriate header.php template file within said Child Theme.
Google Tag Assistance:
For the most part, the above should resolve your problem. You can check whether the Tracking code has been correctly installed by:
Reviewing the code within the Source Code
Installing Google Tag Assistance within Chrome
Exception:
Again, the above should be enough to resolve your issue. Some themes however, do create different headers, for different pages of the site. For example: An eCommerce site may want a different header on their shop pages to their Blog Pages. To achieve this, header template files, such as below would be created:
header-shop.php
header-blog.php
header-ppc.php
To then 'call' each header, the following example PHP entry would be placed within the relevant template file(s):
<?php get_header( 'shop' ); ?>
'shop' being whatever word appends the header- file name. In this case, 'shop', 'blog' and 'ppc'.
You do not need to worry much about this. All you need to do, is head into the root of your theme as follows:
wp-content > themes > theme-name
Look for any files with begin with header- and ensure they contain the Google Tracking code.
In the event you are using a Child Theme, simply copy the header- files over to the root of your Child Theme first and then modify accordingly.
Hope this helps.

Wordpress Form Submit button GETS (or POSTS) form data to external page

We have a wordpress website that does marketing display, but now we want to allow a customer to submit an email and selection to a separate website with a landing page that will handle the backend DB work and finish them in the other website.
Something like,
www.ourmarket.com/getdata (on Submit button click GETS to...)
www.ouradminsite/landingpage.aspx (which processes the data that the use will not see then...)
www.ouradminsite/login.aspx (where the user can now login)
I am not familiar with WP at all, but I was able to create a page with a form that has the textbox/combobox I need.
I thought it would be something simple, but somehow it seems not. I read about AJAX and doing something in functions.php and creating a custom .js file, but when working on the marketing site I find no way to add this type of function in.
My fall back is to have the WP page just have a link to a generic landing page where they enter data, but it would be visually jarring to the customer unless I duplicate the WP site for one page.
Is there an easy way to just tell WP to redirect to an external page with a GET?
UPDATE--------------
I like to think I'm making progress. I found a link that may have given me a good start. I added a function to the functions.php file located in my WP theme. It starts like this:
add_action("gform_post_submission_4", "set_post_content", 10, 2);
function set_post_content($entry, $form){
//Gravity Forms has validated the data
//Our Custom Form Submitted via PHP will go here
// Lets get the IDs of the relevant fields and prepare an email message
$message = print_r($entry, true);
// In case any of our lines are larger than 70 characters, we should use wordwrap()
$message = wordwrap($message, 70);
// Send
mail('myuser#mycompany.com', 'Getting the Gravity Form Field IDs', $message);
**wp_redirect("http://my.hearbuilder.com/hellomoto.aspx",301);**
}
From there I tried to edit the function to do that wp_redirect, just a simple one to start. This is added under the mail statement:
wp_redirect("http://my.hearbuilder.com/hellomoto.aspx",301);
From this link, when I fill out the form I can get the email, but the new page did not display. I added the exit; line and still got the same result, the page seems like it hangs.
The end result is that I need to have the new website landing page display (after it processes the data from the Wordpress form.
What am I still missing?
yes use wp_redirect()
if($_POST):
$textbox=$_POST['textboxname'];
$url= 'url'.'?custom=hello&textbox='.$textbox.'&anothervalue='.$anothervalue;
wp_redirect($url);
exit;
endif;
you can easily add the variables to the string as needed. The easiest way to control the url properly is to post the information to the same page , catch the post and redirect (place before get_header call or any output has started)
The other way is php Curl which is more difficult esp when dealing with .asp pages, but if you have access to the other server it makes figuring it out easier!

Hide Wordpress dashboard?

I'm new to wordpress and a bit confused with something. I'm trying to build a classified marketplace type of website for myself. I am NOT building this for a "client". I will probably be using a hack of several different plugins as my coding skills are not up to par. Eventually I will hopefully have lots of users who will be composed of buyers & sellers.
My question pertains to the WP dashboard. When buyers/sellers sign up for my site, will they be able to see the backend WP dashboard? I would prefer that they NOT be able to access a backend dashboard at all let alone a WP branded one. Is this possible? If so any clue as to how this might be accomplished?
thank you Brian
Normal users do not actually see the 'backend' WP dashboard. What they are seeing is a 'profile' type page meant for the original functionality of wordpres; being a blog.
If you do not want users to go to this page when they log-in, you can use a couple of hooks. Here is some code that redirects to the front page after logging-in and logging-out. This goes in your functions.php file.
add_action('login_form', 'ang_redirect_to_front_page');
add_action('wp_logout', 'go_home');
function ang_redirect_to_front_page() {
global $redirect_to;
if (!isset($_GET['redirect_to'])) {
$redirect_to = get_option('siteurl');
}
}
function go_home(){
wp_redirect( home_url() );
exit();
}
And, if your theme is still displaying the menu at the top of the screen that allows the users to go to this 'profile' area, you can go into your footer.php file and remove this:
<?php wp_footer();?>
However, if you do this, then you will not see it as the admin either.
WordPress is might not be the thing to use for that kind of website, even with a bunch of plugins. Read up on other content management systems just incase.
This link might answer your question:
http://buddypress.org/support/topic/how-to-prevent-non-admins-from-accessing-wp-admin-dashboard/
You can also add this to your theme's function.php file:
// DISABLE ADMIN BAR FOR ALL USERS
show_admin_bar( false );
If you are not too used to wordpress, use WOOCOMMERCE plugin. Its completely free and well documented

Why Facebook like and send button is not getting the correct url - Wordpress

in my website http://youmark.it/ I have in the home page post and in all other single post pages the same number of like, also the send button once you click is showing the Facebook Page url and not the Post url.
I have integrated all stuff for open graph, if you look at the source code it seems to be ok but still doesn't work after few changes I did. Also in the Facebook Debug tool everything shows correct.
Does Facebook need time to get updated or am I doing something wrong?
You have all your like buttons “pointing” to the base URL of your website.
If you want them to like the individual article, then include the URL to that article in the href parameter of the <fb:like> tag.
Try to like this url: <?php the_permalink() ?> instead?
<iframe src="//www.facebook.com/plugins/like.php?href=<?php the_permalink() ?>&send=...
???

Resources