OpenX: Allowing banner links to use the host of the page the banner is being displayed on - openx

My client has a website with many subdomains, each representing a different "client":
http://www.store.com <- Main store; also the default OpenX "Website" host in admin.
http://client1.store.com <- Client store
http://client2.store.com <- Client store
...
http://client222.store.com <- Client store
A lot of the banners are internal links. For those internal ads, they use relative URLs in that banner's "Destination URL" field, in hopes that the link will use the host of the page the ad is being displayed on. But to no avail, the ads seem to always use the host of the OpenX "Website" that that zone is connected to.
So for these local ads I need the host of the destination URLs to match the page the ads is being displayed on. Any suggestions?

The answer to this question was to set the Banner's URL to something like this:
http://{currenthost}/shoes-half-off
Then pass extra, custom variable currenthost into the invocation code.
If the zone is in Local Mode
Set the variable like this, somewhere before your call to view_local():
$_REQUEST['currenthost'] = $_SERVER['HTTP_HOST'];
$raw = view_local($what, $zoneid, $campaignid, // ...
If the zone is in Javascript Mode
Pass it into openx/www/delivery/ajs.php as a part of the GET string. Turn this:
// ...
if (document.mmm_fo) document.write ("&mmm_fo=1");
document.write ("'><\/scr"+"ipt>");
// ...
Into this:
// ...
if (document.mmm_fo) document.write ("&mmm_fo=1");
document.write ("&currenthost="+window.location.href); // <-- Added
document.write ("'><\/scr"+"ipt>");
// ...

Related

Google Optimize - create A/B test with dynamic URL

i'm from business and I would like to ask is it possible to create A/B test with dynamic part of URL?
API of backend application returns calculation ID for every visitor and its included on URL.
For example:
We have main URL www.example.pl and I want to create A/B test with redirect to dynamic URL:
www.example.com/calculation/(calculculation_id)
Is it possible?
If your goal is to redirect from https://www.example.com/product/laptop/12345
to https://www.example.com/product/laptop-test/12345 for each product and not for the product 12345.
Select test type redirect
Set up redirect rules for each variant
Customize your page targeting rules with "contains" or "starts with."
Customize your advanced redirection"
1.Set up redirect rules for each variant
Find in domain/path com/product
Replace with com/product-test
Add/modify query parameters/fragments (leave blank)
Original: https://www.example.com/product/laptop/12345
Redirect: https://www.example.com/product-test/laptop/12345 (see point 3.Customize your advanced redirection)
! Do not worry if you are entering the specific product 12345 this value seen by the system as variable xxxxx !
2.Customize your page targeting rules with "contains" or "starts with."
Modify the page targeting rules to ensure that we include any URL containing example.com/product.
3.Customize your advanced redirection.
In our example the text "com/product" is replaced with "com/product-test".
This is the site where you can find more information :
https://support.google.com/optimize/answer/6361119?hl=en
Yes, you can do that in different ways. I'd suggest using Feature Flags approach in your A/B test in order to have a flag to generated the dynamic next URL from the API.
I'll try to summarize in two steps that you should go:
Add a Javascript in the Optimize Visual Editor for. Example here. The idea is this script to add a new flag:
window.FeatureManager = window.FeatureManager || {};
window.FeatureManager.variant_1_to_change_the_url = true;
On your own script, look at this flag to call the backend API in order to get the calculated URL:
// in case of the variant 1
if (window.FeatureManager && window.FeatureManager.variant_1_to_change_the_url) {
// calls the API passing this flag to get the new URL
const redirectURL = fetch('my_endpoint', true/false); // true/false could be the variant verification
location.href = redirectURL; // this is a sample, you can change the URL however you want
} else {
// the original variation
}

How to track multiple websites moving to one domain with Google Analytics

I am managing multiple websites that will soon move to one domain with each respective market being contained in a sub-directory e.g www.example.com/uk/.
The current situation is that all markets have their own GA property. I was wondering what the implications would be in just leaving the current setup as is?
I imagine GA alerts will fire implying that GA tracking is 'missing' across the website. Or would it be recommended to set the cookiePath field for each respective in the analytics.js create command?
The requirement is that each market is to have their own GA property giving them more flexibility.
Make translation table
function getPropertyId(){
var propertyIDs = {
'uk' : 'UA-24574-1',
'de' : 'UA-32656-4',
'fi' : 'UA-54544-6'
};
var fallBackId = "UA-Falback";
var path = window.document.location.pathname.split("/");
if(path[1]){
var propID = propertyIDs[path[1]] ? propertyIDs[path[1]] : fallBackId;
return propID;
}
else {
return fallBackId;
}
}
Use it when setting Property ID
ga('create', getPropertyId() , 'auto');
Request URI
You can expect troubles with Request URI variable, because:
From comment:
#GKyle Imagine, your current URL is mycompany.uk/page.html and new URL will be mycompany.com/uk/page.html. In old setup will be Requested URI /page.html in new /uk/page.html. There will be inconsistency if you will do nothing. But if you set up a filter removing /uk, etc..
Wonderful regex: ^(/(uk|de|au|en)\b/?)(.*)
From here: RegExp - remove /en or /de from pathname string and return rest
Rewrite string is /$A3
Create Advanced Filter
And please, TEST IT BEFORE!
Result
You can smoothly change tracking from multiple domains under one main domain if you keep setting Property ID.
Keep in mind possible changes in certain reports, specially path based reports.

How to remove _ga query string from URL

I have a multidomain website for which there is GA tracking. Recently we moved to Universal Analytics and noticed that whenever the domain is changed (from US to Korean/Japanese), a _ga=[random number] is appended to the URL
i.e. from
abc.com
when i click on the japanese site, the URL becomes
japanese.abc.com/?_ga=1.3892897.20937502.9237834
Why does this happen?
How can I remove the _ga part of the URL?
Appreciate your help.
This is needed for cross-domain-tracking (i.e. track people who cross domain boundaries as one visitor and not as one visitor per domain). If you want cross domain tracking you cannot remove this. The _ga - part is the client id which identifies a session and since it cannot be shared via cookies (which are domain specific) it has to be passed via the url when the domain changes.
Since somebody set your site up for cross domain tracking I guess you actually want this (it does not happen by default). The parameter is a necessary side effect of cross domain tracking with Universal Analytics. If you do want this look in the tracking code for any of the linker functions mentioned in the documentation and remove them.
Updated to answer the questions from the comment.
Is there no way to remove the _ga string and still have the cross
domain facility?
No, currently not. Browser vendors work on better ways of cross
domain communication so there might be something in the future, but
at the moment the parameter is the best way.
Also, what if some user randomly changes the _ga value and presses
enter? How will GA record that?
If the user happens to create a client id that has been used before
(highly unlikely) his visit would be attributed to another user.
Realistically Google Analytics will just record him as a new user.
Updated
For those who like to play I did a proof of concept for cross domain tracking without the _ga parameter. Something along those lines could be developed further, as-is it is not suitable for production use.
Update: David Vallejo has a Javascript solution where the _ga parameter is removed via the history API (so while it is still added it is for all intents and purposes invisible to the end user). This is a more elaborate version of Michael Hampton's answer below.
I'm using HTML5 history.replaceState() to hide the GA query string in the browser's address bar.
This requires me to construct a new URL having the _ga= value removed (you can do this in your favorite language) and then simply calling it.
This only alters the URL in the address bar (and in the browser's history). Google Analytics still gets the information passed in via the query string, so your tracking still works.
I do this in a Go html/template:
{{if .URL.RawQuery}}
<script>
window.history.replaceState({}, document.title, '{{.ReplacedURL}}');
</script>
{{end}}
I was asked to remove this tag after it started showing up when we split our website between two domain names. With Apache Rewrite Rules:
RewriteCond %{QUERY_STRING} _ga
RewriteRule ^(.*)$ $1? [R=301,NC,L]
This will remove the tag, but will not be able to pass the _ga params to Google Analytics.
If the user doesn't mind a short refresh, then adding this code to every page
<?php
list($url, $qs) = preg_split('/\?/',$_SERVER['REQUEST_URI']);
if (preg_match('/_ga=/', $qs) ) header( "refresh:1;url=${url}" );
?>
will refresh after a second, removing the query string, but allowing the Google Analytics action to take place. This means that by the time your user has bookmarked or copied your URL, the pesky _ga stuff has long gone.
The above code will throw away ANY query string. This version will just strip out the '_ga' argument.
$urlA = parse_url($_SERVER['REQUEST_URI']);
$qs = $urlA['query'];
if (preg_match('/_ga=/',$qs)) {
$url = $urlA['path'];
$newargs = array();
$QSA = preg_split('/\&/',$qs);
foreach ($QSA as $e) {
list($arg,$val) = preg_split('/\=/',$e);
if ($arg == '_ga') continue; # get rid of this one
$newargs[$arg] = $val;
}
$nqs = http_build_query($newargs);
header( "refresh:1;url=${url}?${nqs}" );
}
You can't stop Google from adding the tag, but you can tell Analytics to ignore it in your reports. Thanks to Russ Henneberry for this: http://blog.crazyegg.com/2013/03/29/remove-url-parameters-from-google-analytics-reports/
It was written before Universal was released, so the language is outdated - now you create a new "view" (rather than "profile"). Creating a new view ensures that you still have the raw data in your default view (just in case you ever need it), so it's really the best solution (keeping in mind that you can't ever apply new settings retroactively in G Ax). Good luck!
You can't remove the _ga parameter from the URL on the website...BUT you can use an Advanced filter in Google Analytics to remove the query parameter from the reports!
Like this:
1) Field A: Request URI
Pattern: ^(.+)\?_ga
2) Field B: not needed
3) Output To -> Constructor
Field: Request URI
Pattern: $A1
This filter that will strip off all query parameters when _ga is the first parameter shown. You can get a lot fancier with the regex, but this approach should work for most websites.
See this page: https://support.google.com/tagmanager/answer/6107124?hl=en
& search for "use hash as delimiter"
Setting this value to true allows you to pass the value through a hash tag instead of through a query parameter
Should fix it
One way to handle this is to use the history.replaceState Javascript function to remove the query string from the URL after the page is finished loading and Google Analytics has done its thing. However, if you remove it too soon, it'll affect GA functionality (one visitor will show as multiple visitors). I've found that the following Javascript (with a 3-second delay)
<script defer src="data:text/javascript,async function main() {await new Promise(r => setTimeout(r, 3000));window.history.replaceState({}, document.title, window.location.pathname);}main();"></script>
I used "window.location.pathname" for convenience so that you can use the same script on many pages. However, you can also do like this (for the top page of the site):
<script defer src="data:text/javascript,async function main() {await new Promise(r => setTimeout(r, 3000));window.history.replaceState({}, document.title, '/');}main();"></script>
Or for a sub-page:
<script defer src="data:text/javascript,async function main() {await new Promise(r => setTimeout(r, 3000));window.history.replaceState({}, document.title, '/something/something.html');}main();"></script>
I did the "data:text/javascript" thing instead of a true in-line script so I could apply "defer" to it, although this probably isn't necessary if you're using a sufficiently long delay value.
You can filter out all (or only include) "?_ga=" parameters in Google Analytics for reporting purposes. I would also highly recommend adding a canonical to the base URL -- or adding the parameters to Google Webmaster Tools -- to avoid duplicate content.

Showing http server response in html

I'm trying to create a page that will check websites for server
status.
So on the page I need to obtain a response code of 200 from the
server, and place an icon on the page to declare status. I now that
there are examples out there, but they are only for individual sites.
This project is to either host locally or my server, so that I have a
list is customer site, and the status of there websites.
Is this possible?
EDIT : I have found a way to do this now, but cannot point the Java to the correct site. What I have done is shorten the www.downforeveryoneorjustme.com/echelonservices.co.uk site to isup.me/echelonservices.co.uk. However, I am having problems doing this. All I
Ultimatly what I want to do is look for It's just you! or It's not just you! within the container ID of: "< div id="container">" within the source of the resulting page of isup.me/echelonservices.co.uk
Here is what I have come up with and failed misserably so far:
<script type="text/javascript">
//Specify where the sctipt should be running the code against.
window.location.protocol = "http"
window.location.host = "isup.me/echelonservices.co.uk"
//Look for the Class ID and output to a variable.
element = document.getElementById('container');
var Status = element.textContent || element.innerText;
//If the "Status" says: UP write UP, DOWN write DOWN and anything else write Status could not be determined!
if (Status=="UP") {document.write('<div style="color:#00BB00;font-family:Arial;font-weight:bold">UP</div>')}
else {if (Status=="DOWN") {document.write('<div style="color:#FF0000;font-family:Arial;font-weight:bold">DOWN</div>')}
else {document.write('<div style="color:#EDA200;font-family:Arial;font-weight:bold">WARNING:<br>Status could not be determined!</div>')};};
</script>

Changing the delimiter from ? to # for Cross Domain Tracking

Trying to do cross domain tracking of links to an commerce site (Volusion); currently produces an error because of the ? delimiter. I see I can
_gaq.push(['_setAllowAnchor', true]);
on the volusion cart site in order to enable seeing # as the delimiter instead.
I'm using the script provided by Luna Metrics xdomain.js which auto tags outgoing links for cross domain tracking. It’s not clear to me what to change in the xdomain.js code to use # instead of ? as the delimiter, or can I make this default change with also using
_gaq.push(['_setAllowAnchor', true]);
on the referring domain where the outbound link is coming from?
You need to use _gaq.push(['_setAllowAnchor', true]) and _gaq.push(['_setAllowLinker', true]) on both ends. In theory you just need them in the receiving end. But usually the receiving end can be both. User can be going from domain A to domain B or the other way around.
After that you'll need to modify the lunametrics script because it won't allow you to send cookies in the anchor as it is today. It has this feature hardcoded. These are the lines that you need to modify in the lunametrics script.
Find this line:
var fullUrl = tracker._getLinkerUrl(jQuery(link).attr('href'));
And modify to this:
var fullUrl = tracker._getLinkerUrl(jQuery(link).attr('href'), true);
Then find this line:
_gaq.push(['_link',jQuery(link).attr('href')]);
And modify to this:
_gaq.push(['_link',jQuery(link).attr('href'), true]);
Here are the reference on these functions:
http://code.google.com/apis/analytics/docs/gaJS/gaJSApiDomainDirectory.html

Resources