I am setting up an A/B test with Google's website optimizer.
I have a page:
wwww.example.com/landingpage
and some variations:
www.example.com/landingpage0
www.example.com/landingpage1
www.example.com/landingpage2
the conversion page is on:
www.subdomain.example.com/goal
Website Optimizer's wizard interface, is not accepting the goal page because it's on "a different domain" and apparently there's no way to proceed with the next step.
However, if I "fake" the procedure, and specify
wwww.example.com/fakeGoalPage
the wizard will allow me to continue the set-up.
What I do next is to put the goal-page code in my real goal page, and hope that the test will work.
My question is if this practice is correct or if you can suggest me a better way to solve this problem..
Thank you
By default, Google Website Optimizer sets its cookies on the current domain (document.domain). So, the cookies from www.example.com won't be available when they convert on subdomain.example.com. The solution to that is to follow the instructions from this help center: Customizing Google Website Optimizer code for multiple subdomains?
Basically:
First, you add the following line just before your control script:
_udn = ".example.com";
Then you change your tracking and conversion scripts to allow for cross domain cookies.
Assuming you're using the async syntax, that means this goes before the gwo._trackPageview.
_gaq.push(['gwo._setDomainName', '.example.com']);
(An alternative is to set your goal as a URL on example.com, create that page, and then place the conversion script as the only thing on that page, and include it as an iframe on the conversion page.)
Related
How can I copy the source code from a website (with javascript)? I want to copy the text that is showing the temperature from this website: http://www.accuweather.com/
I want to copy only the number that is displaying the temperature. Is there a way of copying that exact line from source code on the website? I heard about html scraping. if not javascript, what would be simplest way of doing it? Just copying the temeprature, and displaying it on my webpage.
Well the way you could do something like that in a simple way by loading the site into a hidden HTML element via AJAX and then search DOM for the element you want.
There is also a jQuery command that allows that directly. It would be something like:
<div id='temp'></div>
<script>
$('div#temp').load('https://www.accuweather.com/ #popular-locations-ul .large-temp', { limit: 1 });
</script>
#popular-locations-ul .large-temp is a css locator for the specific elements that contain the temperature.
However for some time web has a security feature called CORS. To be able to load something from one site via AJAX, the target site has to allow CORS headers explicitly. In the case of this particular site, CORS headers aren't present in the site configuration, so that means that any connection that tries to load something via AJAX won't be allowed.
You can only use a command like the above mentioned in a site you control and that you specify to allow CORS headers or in a site who already has this specification.
But as people have told you that's not a good thing from the start due to web sites impermanent nature. Things change a lot. So even if you could get a value in the way I mentioned from some other site, sometime later, the site would change and your code would be broken.
The reason I answered is because you are just learning and need guidance and not trying to do 'serious work'. Serious work would be using an API as people told you.
An web api is a special url you access (something like https://www.accuweather.com:1234/api/temperature/somecity) normally with some kind of security and that responds with the result you need for the function you want. For this kind service CORS is allowed because you are accessing in a secure and 'official' way.
Hope I clarified a bit.
In order to ensure compliance with the Cookie Law when using AMP, I need to be able to block the scripts that install cookies and activate them only once the user has given consent. I'm trying to achieve this on AMP-compliant pages, but I'm having the issues described below.
Upon reading the AMP documentation, I noticed that it is only possibile to insert scripts if the script type is set to “application/ld+json”.
The way we currently handle the blocking and re-activation of scripts once the cookie consent has been provided is to change the script type into plain/text in the page source, then switching it back via javascript only after the consent has been given.
How can we achieve this on an AMP-compliant page?
If it's not possibile insert custom script tags, can I create an “AMP-plugin” or a script accepted by the AMP system that makes me achieve the same?
Is it possible to prevent AMP activation at page load to then activate it with a specific trigger?
Also, we've noticed that the AMP js itself is installing cookies. Can the load of the AMP js also be subject to user consent to cookies?
Thanks in advance for your help.
Cookies might be troublesome either way. AMP sites are delivered via Google CDN - so they run on a google subdomain instead of your own domain. This is done by Google to further accelerate the render speed of the site.
So even if you could write a cookie, its scope would be the google subdomain, instead of your own domain.
There seem to be some work-arounds in context of the amp-analytics plugin:
https://www.ampproject.org/docs/guides/analytics/analytics_basics
Here is a cookie accept sample.
Hope this helps. Normaly it is okay to inform the user only that you use cookies.
If you want block cookie before loading the AMP you must handle it self by a script. Same whren user not accept.
Cookie writing can be controlled by passing in amp-user-notification-id as described in https://github.com/ampproject/amphtml/blob/master/extensions/amp-analytics/analytics-vars.md#clientid
The exact code that you need to use depends on what component is writing the cookies. Is it an analytics vendor or an ad or something else?
I've recently stumbled upon a website called Overlay101 which allows you to create tours for other websites.
I was very interested to see the technique they use to load the third party websites for editing.
When you type the address of the website, it is loaded as a sub domain of the overlay101.com website.
For example, if I type https://stackoverflow.com/questions/111102/how-do-javascript-closures-work - it is loaded as http://stackoverflow.com.www.overlay101.com/questions/111102/how-do-javascript-closures-work
I was wondering how is that subdomain creation achieved and I saw in the source code of the page that JavaScript in injected. I was wondering how was that possible too.
What intrigued me most is that Stackoverflow.com does not allow pages to be loaded within frames - I was wondering how they managed to load up the page so that tour popups could be added.
They simply use wildcard DNS entries to make all subdomains work. They then use the Host header to get the original domain name and download the HTML code of the site. Since they do this on the server side they do not need any frames etc.
It is possible to disable JS at all.
It is possible to disable JS on certain domains by adding them to Restricted Zone for example.
I wonder if it is possible to block/restrict third party domain access other than *.currentwebsite.com for enabled JS in IE.
This could be somehow useful in ad blocking as well as security.
Or am I supposed to write an add-on myself?
I don t know is it possible or not but it is definitely a bad idea as CDNs are highly popular these days and most of the page use these for CSS and JS file as well as image file.
To block ads you can also use hosts file (under system32\drivers\etc folder) if you have the list of the URLs (I am pretty sure you can find a list at the internet) just redirect them some fake address like localhost or a server response nothing.
Here's the thing, I have created a mobile web-app having 6 pages only (main.html, venue.html, program.html... , aboutus.html). Ss you guys can see main.html is the main landing page. We also have native mobile apps for Blackberry and iPhone and these native apps use some of my pages in their widgets. Now the issue is I need to distinguish between the page views or hits in such a way so that I could get a clear idea about from where my page is being requested or viewed and then hide/show some stuff depending upon from where the page is being requested. One interesting thing, as mentioned above main.html is the main landing page of web-version so we never use this page in our native apps. So I need to create a cookie on main.html and wanna check that cookie value on each of 6 pages. By following this approach what I want to do is e.g.
Let us say: If I got a hit from native app for venue.html, then in this case I will not get any cookie value as this user has not visited the main.html and reverse of this if some user has used my web-app/version then he/she has to go through the main.html (user is forced by us to view the main.html page first then others).
So after exploring everything I need you guys help to: 1. How to create such kind of cookie in javascript on main.html? 2. how to check that cookie value on rest of pages to know from where that page is being accessed?
Note: I don't want to store any expiry date/time in cookie and in setcookie method I want to set some constant value instead asking user to set some dynamic stuff through some alert dialog.
Any code snippet will highly be appreciated
Doesn't sound like you are doing any pre-processing on the serving side of the equation. Meaning all your pages are static pages, you might want to look into pre-processing your pages using ASP, PHP, Perl or whatever other programming your server allows. By doing so, you open up the option of tracking movement of the user within your application.