Tag Info

Hot answers tagged

12

When WordPress activates a plugin, it calls the activate_plugin() function. This function activates the plugin in a sandbox and redirects somewhere else on success. It's been used by a few authors to programmatically activate plugin dependencies. There's another function, deactivate_plugin(), that does a similar thing in reverse ... it's actually how ...


11

I'd suggest either a plug-in or a drop-in section of code in your client's functions.php file. The advantage of a drop-in is that you can add it once and never have to worry about activating or managing the system once it's up-and-running. Here's a quick explanation of how to add the Google tracking code to your theme's functions.php file. The code itself ...


7

You basically have to tag the <a> link Google Analytics provides an easy way to track clicks on links that lead to file downloads. Because these links do not lead to a page on your site containing the tracking code, you'll need to tag the link itself with the _trackPageview() JavaScript if you would like to track these downloads. ...


6

Use a plugin. Especially if you want it simple. Because plugin would take care of obscure stuff that won't even occur to you. Duplicate pages in Google index from their own Analytics tags is excellent example of such.


5

This is thanks to EAMann's brilliant answer above, and I thought it might be helpful to the original poster too... I needed a solution to make sure users deactivated my plugin if they uploaded the premium version (to avoid potential conflicts). Previously I detected its state with is_plugin_active and showed an admin error message to prompt users to switch ...


4

If you add tracking code to a theme file you will need to do this on every theme change. It is considered good practice to use plugin for this, like Google Analytics for WordPress. It will use common hooks (that every theme worth using has) to insert code and that way you don't need to think about that when changing.


4

Check header.php and footer.php; sounds like that link is part of your theme and is pulling that script, possibly from a plugin that is supposed to be included with the theme or in the "must use" plugin folder, which is called mu-plugins in wp-content.


4

Hook the script into the footer, which is easy enough. http://wpmututorials.com/plugins/how-to-hook-into-the-footer/ As stated in the post, toss that into mu-plugins, it will track all your site, regardless of domain. GA can sort it out on their end. totally do-able.


3

Absolutely you can keep your analytics code Theme-agnostic. Most analytics code is simply a script, and scripts can (and should) be enqueued using proper hooks. In this case, the relevant hooks require nothing more than Theme support for two all-but-universal template tags: wp_head() and wp_footer(). Keeping the analytics code Theme-agnostic will require ...


3

As far as I know, a plugin can be deactivated in these conditions: manual deactivation failed plugin upgrade remove or rename the containing folder changing the active plugin list in the database Hopefully someone else will come through and add to this if I missed any.


3

Take the GA code from your header and wrap it in a function hooked to wp_head; function __analytics_head() { $options = get_option( 'themename_theme_options' ); if ( !empty( $options['analytics'] ) ) : ?> <script type="text/javascript"> var _gaq = _gaq || []; _gaq.push(['_setAccount', '<?php echo esc_js( $options['analytics'] ...


3

I was hoping you would clarify how you're outputing these links, as per Rarst's comment.. That said, i'm going to assume you're using wp_list_bookmarks to create a list of these links (there aren't many other functions for the purpose). For wp_list_bookmarks there's only one hook available and that's called(ironically) wp_list_bookmarks, which gives you a ...


3

It is were me I'd just use different plugins; not sure if you'll find one that does all of them and if so finding it will be happenstance. Or just code it directly into your theme (unless you are concerned about switching or upgrading themes.) Each of those is very trivial to do. Actually these would make three (3) good additional questions if you want ...


2

I currently do all of these with different plugins. There is no need to look for a combined plugin with so many options. Google Analytics reccomendation - Google Analytics for Wordpress Favicon - many themes include this ability (Atahualpa being one) Meta - any of various SEO plugins as Mike suggested Hope this helps MM


2

If you want to be able to see which of your visitors have subscribed in GA, you need to call an event, a virtual page or a custom variable using an onclick event. Probably best to use an event, so add something like this to the link: <a href="subscribe link" onclick="_gaq.push(['_trackEvent', 'Subscribe', 'RSS', ...


2

You need to find the right setup at GA first. There is an option where you select if you want to use it on a single domain or on multiple domains. Please see the description there as it depends on what you want to do on your site - and you have multiple options. After you've made your mind about how you want to have it configured you should select the ...


2

Google Analytics by Yoast has Custom Code setting to add stuff to tracking code. But says that it is added before trackPageview, while site speed instructions show it added after. Might or might not matter, I don't know. Update Plugin has been updated to support (and default to) site speed tracking.


2

Is it an outbound link? Otherwise it should automatically get tracked (as a page view). If it is outbound, I'd set a class on the custom menu item in Wordpress (using the CSS Classes (optional) field). Then you could trigger that link with JavaScript. For example, with jQuery you could do something like this (assuming you are using the Async version of ...


2

User needs it in his footer so I think you should use conditional page logic. Something like: If ( is_single(postID)) { //insert tracking code } You can also use the post title or post slug, but id is the most reliable. Old Answer I would consider writing a shortcode. Add the following to your functions.php file. You can specify input parameters. In ...


2

You could do something like the following (merely an example, do not take literally): $posts = get_posts( 'posts_per_page=-1' ); foreach ( $posts as $post ) { $url = url_encode( get_permalink( $post->ID ) ); $get = wp_remote_get( "https://www.google.com/analytics/api?visits_for_url=$url" ); if ( $data = wp_remote_retrieve_body( $get ) ) ...


2

Please check out the WordPress Post Analytics Plugin that we (WisdmLabs) have created. http://wordpress.org/extend/plugins/wordpress-post-analytics/ This is available on the WordPress plugin repository as a free download. We link your Google Analytics account to the plugin and pull data from the Analytics backend to showcase stats right inside any post. ...


2

This one is brand new: http://wordpress.org/extend/plugins/social-media-tracking/ and it sounds like it does what you want. But be watching Joost de Valk's GA plugin. He mentioned just a few days ago in this thread that he's working on it right now. He's a prominent plugin author in the community and does good work. If you want to implement your own, you ...


2

The reason is you are using HostGator and enable the feature is Google Analytics Integration, by enable this one, HostGator will automatically add this snipped of code into your main website and all of it sub or add-on domain: <script src='/google_analytics_auto.js'></script></head> I my self also faced with this issue, my main website ...


1

You should be able to use Contact Form 7 and then attaching a jQuery click event to the submit button: $(".wpcf7-submit").click(function() { _gaq.push(['_trackPageview', '/G1/whatever']); });


1

This seems to be a valid answer: Use Contact Form 7. In the "Additional Settings" box enter the following: on_sent_ok:"_gaq.push(['_trackPageview', '/G1/whatever']);" Where /G1/whatever is the Goal URL you set on your Google Analytics options page.


1

have played around with the google analytics dashboard plugin, but there doesn't seem to be any way to achieve what I am after There isn't, because to use that plugin in the manner you want, you need a different GA account for each author to track each author, and select that account in the plugin settings. Like you would have to do with any ...


1

You can set custom variables in analytics that would contain the author name. If you happen to use Yoast's google analytics plugin, one its options will let you do just that. That would be the first step. Collect data for a while (a month, maybe) and see if you're getting what you want. After that, you'll probably have to write something (or have it ...


1

You don't need to pick a theme ahead of time. But when you do pick a theme, be sure it's one that follows WordPress best practices for design (i.e. uses wp_footer() in the appropriate location). For all of my hosted client sites, I use a mu-plugin to add analytics. This way, they can change their themes whenever they want without losing their analytics. ...


1

If you are using self-hosted WordPress, i.e. that you downloaded yourself via wordpress.org, and installed yourself on the server account provided by your hosting provider, then: yes; you can FTP into your WordPress installation (and in fact, almost have to do so, in order to install it). If you are using the hosted blogging service wordpress.COM, then: no, ...



Only top voted, non community-wiki answers of a minimum length are eligible