I have a WordPress blog that's hosted within my site (http://www.mysite.com/blog) and my website itself is based on ASP.NET.
I'm tracking referrers within ASP.NET upon session start and storing them within a session variable to save into my database either after a session expires or after a visitor converts to a member.
How can I track the referrers for visitors that come to the blog first and click on a link to a page within the website? Is there a way in WordPress that I could pass the referrer using a query string?
When they land on the blog drop a cookie with the original referrer.
Then read this from the app.
Whip up a plugin to do something like this:
if( !isset($_COOKIE['ref']) ) {
setcookie(...);
}
If you feel like a hack you could just add this to WP's index.php, but a plugin would be the more portable, clean option.
Related
I have done multi languages on my web site.
When user visits page at first time works mechanism that detects country and language.
After is occurring reloading page and data is added to current session.
Problem is that when I try to share links in social networks I get empty data, because social bot does not have session mechanism therefore web server returns empty page without text.
How I can resolve this issue or may be change something in architecture.
To share please a good prartic about this.
Don't use sessions for this. If you want to share the page URL with the right language, make sure this language is part of the URL. A simple way to do this is to use a query string. Your URL could look like this: http://www.example.com/page?language=dutch
In PHP you can use $_GET to read which language to use:
<?php
if ( isset( $_GET['language'] ) ) {
// Display page in specified language
} else {
// Display page in default language
}
I am working on a website where I need to use the login form to log into a different site and then bring the member's area from that site over to the one I am building.
I have access to both sites and can make changes on either one. I would incorporate the code from the old one directly but it is in ASP and I'm working with PHP.
Any ideas? The purpose would be for someone to login to the site through site A (no problem) then get the information from site B (no problem) and present it in site A (no problem if I use cURL to get the site and break it up then display it on the new one). The issue I get into is the links that are on the new site and gathered from the old site will still point to links on the old site. Maybe there is a way to dynamically generate those pages on the new site somehow? Or am I going about it all the wrong way?
It's essentially a proxy. You need to parse and rebuild the links in the html source code received from site B. There are no functions available for this, but there are numerous open-source proxy scripts you can take code from.
Glype should be open-source (site appears to be broken now unfortunately).
https://www.glype.com/
You need to split the links to change them depending on where do they point.
Links to css/js should be rewritten to point to the real url (note that ajax content won't work, because you can't do an ajax request to another website)
Absolute links to the real website should be changed to relative
Relative links should point at your website (ex. $new_url = '/viewpage/?page=' . urlencode($url);)
Absolute links to other domains (not the old website that you proxy) should be dealt somehow, think about what do you want to do with them exactly.
I have a website where I am splitting my traffic into two user groups "learners" and "instructors". I hold their user group in a session variable and direct them to the relevant section of their site.
I am having problems with search engines not indexing the site due to them not having the user_type cookie set. Is there a way I can allow the search engine crawler access to both sections of the site (at the moment it gets stuck in an loop from the user_type selection page to the homepage).
I would also ideally like to be able to allow the crawler access to the member-only resources as there will be content that learner drivers will be able to access that I would prefer was only accessible once logged in.
The code checking the session variable user_type is below and is called on every page (hence why nothing is getting crawled)
if($check_exists==TRUE) {
$this->session->set_userdata('referrer', current_url());
if (strlen($this->session->userdata('user_type'))==0) {
redirect('/user_type/');
}
} else if($check_exists==FALSE) {
if (strlen($this->session->userdata('user_type'))>0) {
redirect('/home/');
}
}
The concept you are using to handle both user types (learner and teacher) is wrong from a SEO perspective. In most cases, you should never have to different content sharing a single URL.
In your case, http://www.road2driving.co.uk/home redirects to http://www.road2driving.co.uk/user_type if no cookie is found. A web crawler will ignore your cookie, and will be caught in a loop. If you want to index both pages, you need to drop the cookie based navigation and create 2 separate sections of your site.
http://www.road2driving.co.uk/home should be your current http://www.road2driving.co.uk/user_type page. Meaning that /home will display 2 links for the learner and teacher sections.
Then create a learn section and a teach section, using a sub-folder for example. You will have:
http://www.road2driving.co.uk/home
http://www.road2driving.co.uk/learn/
http://www.road2driving.co.uk/teach/
That way all sections of your site be accessible by a crawler.
This issue has been driving me up a wall.
I've been working on a mobile website for a friend who uses wordpress. I'm attempting to modify a wordpress plugin that "rethemes" each page for mobile users. I want the plugin to do it's normal thing ("retheme" the page) iff the user is on the blog page, otherwise (if the user visits a different page, he will be redirected to a different address (the address of the mobile website).
In order to do this, I have to be able to detect whether I'm on the blog page, or a different page when the functions in the plugin are run.
I tried condtionals like is_home, is_page(id), ect., but none of them work. I also tried parsing the url and attempting to determine the page that way, but I can't.
I'm just getting my feet wet with PHP, so I'm really not sure what to try next.
To restate my question: How can I determine whether I'm on a certain page within a wordpress plugin function?
The plugin, for the record, is "Wordpress PDA & iPhoned" (http://imthi.com/wp-pda/)
Here's the relevant code:
function PDAPlugin() {
if(true) {
header("Location: http://adavidcreation.com/mobile");
exit;
}
...
}
This works, but I want to change the if statement to only be true if it's NOT the blog.
Any help would be greatly appreciated!
Try using this, which should retrieve the page id: $id = get_option('page_for_posts');
If this doesnt work -> https://wordpress.stackexchange.com/
I have noticed some blogs using what looks like a wordpress plugin to detect if the website visitor came from google search. how is this done?
http://omninoggin.com/projects/wordpress-plugins/wp-greet-box-wordpress-plugin/
The plugin checks the $_SERVER['HTTP_REFERRER'] value (since it is written in PHP) which holds the referrer of the loaded page, then parses it to check what site the user came from to welcome them accordingly.