I've installed Google Analytics several times in the past without trouble. However, recently i've installed GA on a .asp page for the first time. Google Analytics dashboard tells me the tag is properly installed, but ever after several days, i can't see any data.
alt text http://img704.imageshack.us/img704/4584/tracking1.jpg
alt text http://img340.imageshack.us/img340/8272/tracking2.jpg
Is there any special setup required for .asp pages or windows servers?
Unfortunately, I don't have the option to install GAHelper.
ASP pages should not require any special configuration. You can check if the tracking code is being outputted correctly by using View Source in your browser, that's all it takes from the server.
The next step would be using Firebug or a similar tool to see if the request to the Analytics servers is going through properly.
Finally got this working by using Google Analytics Asynchronous Tracking, using the following code:
<script type="text/javascript">
var _gaq = _gaq || [];
_gaq.push(['_setAccount', 'UA-XXXXX-X']);
_gaq.push(['_trackPageview']);
(function() {
var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
(document.getElementsByTagName('head')[0] || document.getElementsByTagName('body')[0]).appendChild(ga);
})();
</script>
Never quite understood why this didn't work with the usual google tracking code...
Related
It's not easy to get Google Analytics/Google Ads working with CSP. I checked out a number of SO articles including this one, but wanted to see if there was another approach.
I found a pretty easy way to do it in this article, and wanted to post it here in case it may be useful to others. I'll post it here as an answer.
I found a pretty easy way to do it in this article:
...move the Google Analytics code snippet to an external code file,
hosted on a domain that is already allowlisted by your script-src
directed, such as the primary domain of your website.
The script originally supplied by Google was:
<!-- Google tag (gtag.js) - Google Analytics -->
<script async src="https://www.googletagmanager.com/gtag/js?id=UA-##########">
</script>
<script>
window.dataLayer = window.dataLayer || [];
function gtag(){dataLayer.push(arguments);}
gtag('js', new Date());
gtag('config', 'UA-##########');
</script>
I went to https://www.googletagmanager.com/gtag/js?id=UA-##########, downloaded the script, and added this to the bottom of it:
window.dataLayer = window.dataLayer || [];
function gtag(){dataLayer.push(arguments);}
gtag('js', new Date());
gtag('config', 'UA-##########');
I saved it to my website. I added this:
<script async src="/script-saved-to-my-website.js"></script>
...inside the head section. (Google ads seems to want it inside the head section for some reason).
I added csp policy as described in the above article.
I connected Google Analytics 4 to Google Ads using the "connect to Google ads" feature I found in Google Analytics. Note: you have to have Google Ads in Expert mode, not Smart mode, for this to work.
I set up a Conversion goal on Google Ads.
And... it's working. :) I can see my stats on Google Analytics and my conversions on Google Ads.
I've looked at the configuration options for GitLab CE regarding analytics and found that if I configured the following line in /etc/gitlab/gitlab.rb, I would be able to track my GitLab CE usage:
gitlab_rails['extra_piwik_url'] = 'my.piwik.hostname'
gitlab_rails['extra_piwik_site_id'] = '2'
After doing a gitlab-ce reconfigure, I can see in the HTML source of the pages the following tracking code:
<script>
var _paq = _paq || [];
_paq.push(["trackPageView"]);
_paq.push(["enableLinkTracking"]);
(function() {
var u=(("https:" == document.location.protocol) ? "https" : "http") + "://my.piwik.hostname/";
_paq.push(["setTrackerUrl", u+"piwik.php"]);
_paq.push(["setSiteId", "2"]);
var d=document, g=d.createElement("script"), s=d.getElementsByTagName("script")[0]; g.type="text/javascript";
g.defer=true; g.async=true; g.src=u+"piwik.js"; s.parentNode.insertBefore(g,s);
})();
</script>
Unfortunately, looking at the webserver logs of the Piwik server, I do not receive any request. Can someone see something I'm missing?
Even if this is a really old question some possible answers to this:
Do you have an AdBlocker? Disable it to enable tracking.
Do you have DoNotTrack activated? Disable it as this can disable the tracking with Matomo.
For the first point: AdBlocker most likely filter out the scripts needed for matomo/piwik. There is nothing that you can do here.
For the second: By default the DoNotTrack is honored by matomo/piwik. You can change this setting in matomo but please respect your users choice not to be tracked.
(Cross posted here)
Hi,
I have a sandboxed page (specified in my manifest) which is loaded into an iframe in my extension's background page. From within my sandboxed page, I'd like to open a new window and write to it, i.e.:
var win = window.open(); win.document.write('<p>Hello!</p>');
This works from my extension's background page and from regular web pages, but when invoked from either content scripts or my sandboxed page, the window opens, but I cannot access the win object (it's defined, but empty---console.log outputs "Window {}").
I assume this is due to same-origin policies (with every window being given a uinque-origin within the sandboxed environment). However, since the window opens an about:blank page, I'm confused why this would matter.
Is this a feature? Is there a parameter I can add to my manifest to avoid this? And does anyone know of work-arounds that don't involve using postMessage back to my background page? My ideal solution is to have my sandboxed script open a new window and interact with it directly, not with message passing.
I can provide a full example if necessary, but I'm hoping someone might just know off the top of their head. I'm running Chrome 24.0.1312.57 on Mac and 24.0.1312.68 on Ubuntu if that helps.
Thanks,
Hank
Content scripts, by definition, are part of external regular web pages you load so I'm not really sure how your script could work on a "regular web page" but not the content script. Do you mean the code works when you embed it in your own pages, but not in other pages via the content script?
Regardless, if the script is working properly from your background page, you could always try messaging. (more here: http://developer.chrome.com/extensions/messaging.html)
Script for your sandbox/contentscript:
//send message to background page
chrome.extension.sendMessage({todo: "newWindow"});
In background page:
//create a listener
chrome.extension.onMessage.addListener(
function(request, sender) {
if (request.todo === "newWindow") {
//do your stuff here
var win = window.open(); win.document.write('<p>Hello!</p>');
}
});
Per the cross-post here, the issue is indeed that the opened window is given a unique origin. This was intentional as the members of the standards working group (SWG) felt that it would be more secure to not make an exception for about:blank pages where they inherit the sandbox's origin.
However, to get around this issue, at least for my purposes, I can use the following method. First, forget sandboxing. This workaround uses an iframe embedded in a background page with the src url set to data:text/html,.... This gives a unique origin to the iframe so it's no longer in extension space. That means eval can be used and chrome apis cannot be accessed. Unlike in a sandbox, windows opened from the iframe share that same origin as the iframe, allowing created windows to be accessed. For example:
In a background html page:
<html>
<head>
...
<script src="background.js"></script>
...
</head>
<body>
...
<iframe id="myframe"></iframe>
...
</body>
</html>
In background.js:
...
document.getElementById('myframe').setAttribute('src', 'data:text/html,'+
encodeURI('<html><head>'+
'<script src='+chrome.extension.getURL('jquery.js')+'></script>'+
'<script src='+chrome.extension.getURL('myscript.js')+'></script>'+
...
'</head><body></body></html>'
));
...
In myscript.js
jQuery(document).ready(function(){
...
// To receive messages from background.js.
window.addEventListener('message', function(e){ ... } );
// To send messages to background.js.
parent.postMessage({...}, '*');
// To open AND ACCESS a window.
var win = window.open();
win.document.write('Hello'); // Fails in sandbox, works here.
// Eval code, if you want. Can't do this from an extension
// page loaded normally unless you allow eval in your manifest.
// Here, it's okay!
eval( 'var x = window.open(); x.document.write("Hi!")' );
// No chrome apis.
chrome.log( chrome.extension ); // -> undefined
chrome.log( chrome.windows ); // -> undefined
// No direct access to background page (e.g., parent).
chrome.log( parent ); // -> Window with no properties.
...
});
I suspect this is a total newbie question, but I seem to be missing the basics here. I am NOT new to coding and have a lifetime of experience (27 years) with various languages, but the plugin process is eluding me.
I have developed custom bookmarking system in php & js, it works great and I've been using it for months as I develop it.
I simply want to get the url of the page in the active tab and pass it to my php handler. I want my web site script return the html form into the popup. I can think of a thousand ways that "should" work.
ALL the code examples I am finding seem to over-complicate what should be a simple task.
In short I just want:
<script type="text/javascript">
<!--
var loadurl = "http://my.site.com?theUrl=" + window.location;
location.href = loadurl;
//-->
</script>
And have that page show in the popup. So far I'm at a loss. Even tried ajax calls etc.
Can somebody clue me in on how to achieve this simple task? Maybe I can get started writing extensions with the info.
For the record, most of the examples I have found are deprecated under manifest 2.0
Manifest 2.0 introduces a new feature contentSecurityPolicy. All external resources are blocked by default. For the best practice, you should include all needed asset files in the extension. The communication between your extension and your service (php side) is only data using XHR2.
So, In order to make bookmark extension work, I guess you need to something like this:
Add your service's domain to permissions array
{
...
permissions: ['*://my.site.com/*', 'tabs']
}
Move all javascript from popup.html to popup.js. In popup.js, You create a ajax request to your bookmarking service. More document here
function addBookmark(url) {
var xhr = new XMLHttpRequest();
xhr.open("GET", "http://my.site.com/new_bookmark.php?url=" + encodeURIComponent(url), true);
xhr.onreadystatechange = function() {
if (xhr.readyState == 4) {
var resp = xhr.responseText;
// handle service result here
}
}
xhr.send();
}
chrome.tabs.getSelected(null,function(tab) {
addBookmark(tab.url);
});
We have developed a portal using the code from the customer portal. But we haven't used the customer portal solution on the CRM server. Everything is working fine except caching prevents updates to show on the portal.
In CRM 4 I used this solution http://pogo69.wordpress.com/2010/11/05/caching-revisited-crm-4-0-sdk-advanced-developer-extensions/. But this doesn't work in CRM 2011 because Microsoft.Xrm.Client.Caching is different. How do I clear the cache for 2011?
Any help or thoughts would be greatly appreciated.
Thanks!
Make sure that you have a cache invalidation URL configured. The PRM portal has a service that invalidates the cache with any update/create event (managed by a plugin registered on all entities).
Go To Settings -> Web Notification URL, either update the URL to the Cache.axd file or create a new entry.
If this is all in place, I would make sure that the plugin that takes care of calling the cache invalidation is working/registered as it should be.
Hope that helps
See the following article for more details on the Web Notification URL.
Set Up Cache Invalidation to Refresh Changes on the Website
I found that removing the preloadcache parameter & value from URLs bypasses CRM's cache. Not ideal but it worked. Your mileage may vary...
<script type="text/javascript">
bypassCrmPreloadCache(); // DE_WR_15706 Bypass 30sec cache to get latest version #
function bypassCrmPreloadCache() {
var ParentURL = window.parent.location.href;
var nStartPreloadcache = ParentURL.indexOf("preloadcache");
if (nStartPreloadcache > 0) {
// Parent URL is cached
var nEnd = ParentURL.indexOf("&", nStartPreloadcache);
if (nEnd == -1) { // Special case: no ampersand => preloadcache is last argument.
nEnd = ParentURL.length; // End of URL is end of preloadcache's value.
}
var strPreloadCacheParamAndValue = ParentURL.substr(nStartPreloadcache, 1 + nEnd - nStartPreloadcache);
// Remove preloadcache-parameter from URL
ParentURL = ParentURL.replace(strPreloadCacheParamAndValue, "");
if (ParentURL.charAt(ParentURL.length-1) == '&')
ParentURL = ParentURL.slice(0, -1); // Ensure URL not terminated by an unnecessary '&'.
// Load URL in parent Window, bypassing the cache
window.open(ParentURL, "_parent");
}
}
</script>