I've tried to implement google analytics experiments to one of my pages. I added the following code:
<!-- Google Analytics Content Experiment code -->
<script>function utmx_section(){}function utmx(){}(function(){var
k='122644017-3',d=document,l=d.location,c=d.cookie;
if(l.search.indexOf('utm_expid='+k)>0)return; function f(n){if(c){var
i=c.indexOf(n+'=');if(i>-1){var j=c. indexOf(';',i);return
escape(c.substring(i+n.length+1,j<0?c. length:j))}}}var
x=f('__utmx'),xx=f('__utmxx'),h=l.hash;d.write( '<sc'+'ript src="'+'http'+
(l.protocol=='https:'?'s://ssl': '://www')+'.google-
analytics.com/ga_exp.js?'+'utmxkey='+k+ '&utmx='+(x?x:'')+'&utmxx='+(xx?
xx:'')+'&utmxtime='+new Date(). valueOf()+
(h?'&utmxhash='+escape(h.substr(1)):'')+ '" type="text/javascript"
charset="utf-8"><\/sc'+'ript>')})(); </script><script>utmx('url','A/B');
</script>
<!-- End of Google Analytics Content Experiment code -->
to the head but my console gives the following output:
A Parser-blocking, cross-origin script, https://ssl.google-analytics.com/ga_exp.js?utmxkey=122644017-3&utmx=&utmxx=&utmxtime=1475762834841, is invoked via document.write. This may be blocked by the browser if the device has poor network connectivity.
Failed to execute 'write' on 'Document': It isn't possible to write into a document from an asynchronously-loaded external script unless it is explicitly opened.
I have tried to google this error, even search this place before posting, but I have no idea why I am receiving this. Is there any one here that could point me in the right direction to solve this?
Related
I have problems configuring a very basic goal in Google Analytics.
My goal page is: https://www.lifeconnections.pe/?action=ff1
I configured the goal as a destination and regular expresion using "/?action=ff1" as the goal text
In Google Analytics the "/?action=ff1" appears as the page visited in the "behavior>site content>all pages" report
Even then, the goal is not being registered.
What can be the error I am making. In Google Analytics documentation can't find the error.
Thanks,
Try to use your string value defining contains instead of regex or try to set this value for regex:
\/\?action=ff1
when I checked my google analytics > acquisition > search console > landing page
understand that I have 2 URLs for each blog post.
for example:
blog/429/legal/اسقاط-کافه-خیارات-به-چه-معناست/
and
/blog/429/legal/%D8%A7%D8%B3%D9%82%D8%A7%D8%B7-%DA%A9%D8%A7%D9%81%D9%87-%D8%AE%DB%8C%D8%A7%D8%B1%D8%A7%D8%AA-%D8%A8%D9%87-%DA%86%D9%87-%D9%85%D8%B9%D9%86%D8%A7%D8%B3%D8%AA/
Both refer to one blog post.
But the main problem is statistics:
URL #2 have 0 Impressions, clicks and CTR but correct position. Also URL #1 have correct Impressions, clicks and ctr, but incorrect position.
My blog posts have canonical tag and I check all internal link building. I used all linked with same form (for example: example.com/blog/429/legal/اسقاط-کافه-خیارات-به-چه-معناست/)
now
1- what is the source of problem and
2- how to fix it?
This is an issue of Google Search Console. The url is sent to Google Analytics in encoded form and the tool manages to convert it to show ad decoded. When it retrieves it from the search console it shows it as it receives it. I don't think there is an effective solution with the two tools, however you can export data and manage them in another tool, for example with Javascript (i.e. in Spreadsheet and Google Apps Script) you can de decode a URI with only one operation so after that you can build a table (in Spreadsheet) that finds the matches and compare the metrics.
<div id="get_url_encoded">/blog/429/legal/%D8%A7%D8%B3%D9%82%D8%A7%D8%B7-%DA%A9%D8%A7%D9%81%D9%87-%D8%AE%DB%8C%D8%A7%D8%B1%D8%A7%D8%AA-%D8%A8%D9%87-%DA%86%D9%87-%D9%85%D8%B9%D9%86%D8%A7%D8%B3%D8%AA/</div>
<br /><br />
<div id="set_url_decoded"></div>
<script>
var uri = document.getElementById("get_url_encoded").innerHTML;
var uri_dec = decodeURIComponent(uri);
document.getElementById("set_url_decoded").innerHTML = uri_dec;
</script>
https://jsfiddle.net/michelepisani/de058c4o/5/
I have been trying to integrate optimizely into google analytics and it has proved a bit difficult than I anticipated. I am doing it through gtm which makes it slightly complicated. I have created a macro
function() {
dimension = optimizely.allExperiments[experimentId].universal_analytics.slot;
experimentIds = optimizely.activeExperiments;
variationName = optimizely.variationNamesMap;
experimentDetails = variationName + "|" + experimentIds;
return experimentDetails;
}
and joined it to a custom dimension in universal analytics tag which means this will be fired on every page but the dimension always comes back as:
'Running command: ga("set", "dimension14", undefined)'
I will really some help on this as I am struggling and the optimizely team dont know what to do either.
Thanks.
While Optimizely is best installed directly onto your page, it is possible to install Optimizely using Google Tag Manager (GTM), which is discussed here, with a complete walk through. This will ensure Optimizely fires before GA (or any other tag):
https://help.optimizely.com/hc/en-us/articles/200040095-Implementing-the-Optimizely-Snippet#tag_manager
The next part is troublesome - how can you integrate Optimizely with Google Analytics? To do so, you must insert a line of code before the GA tracking call is made ( ga('send','pageview') ). To do this, you must modify the JS in the GA call to look like the code below.
Please note, unless GTM allows you to modify their GA add on, you will need to add a custom integration in GTM for GA to place the modified code.
// Optimizely Universal Analytics Integration code
window.optimizely = window.optimizely || [];
window.optimizely.push(['activateUniversalAnalytics']);
ga('send', 'pageview');
The 'activateUniversalAnalytics' call is similar to the macro you've written above, where all it does is pass your experiment ID# (or name) and the variation # (or name) to the custom Dimension you've assigned to GA in Optimizely. One benefit of using Optimizely's integration is you can change the Dimension number per experiment inside Optimizely without making any changes to your page's source code.
If you need further assistance with this, please contact support#optimizely.com (full disclosure, I am an Optimizely employee).
I have setup a new Universal Analytics tracking and would like to store ClientID in one of the custom dimensions slots.
The tracking tags are implemented through Google Tag Manager (using the predefined UA tag) and I am having the difficulty to passing the Client ID (via custom JavaScript Macro) with the basic pageview request.
I have named my tracker so that I can access it and this code runs without any error in console, however when used with GTM, it's returning an error.
ga.getByName('trackerGTM').get('clientId'))
produces an error:
Uncaught ReferenceError: ga is not defined
Any tips?
I assume you're firing the pageview {{url}} matches RegEx .*, correct? Could be that Universal hasn't loaded yet. Have you tried {{event}} equals gtm.dom? I haven't tested this, but it's a thought.
EDIT:
This looks like a bug. I was able to run:
function(){
var client = ga.getAll()[0].get('clientId');
return client;
}
And have it spit out the client ID with no problem.
The real problem is that GTM (Google Tag Manager) creates an object that is NOT called ga (it creates an object named ga followed by a random number), that's why 'ga' is not defined. You should try something on the lines of using the tag manager to put that client id into a javascript variable so you can access it from the page)
I was reading up on setting client ids and came across this blog link about accessing client ID in GA while using Google Tag Manager. Might be helpful.
Accessing Client ID in GA using custom dimensions
I am trying to use PHP to fire hits at Google to track newsletter opens and clickthroughs. I want to use the same technique for both clickthroughs and opens since the clickthroughs will go to sites outside of my own control - I want to be able to report on the clickthrough rates of the newsletters regardless of where the clicks go to. I was thinking of trying code.google.com/p/php-ga/ but there is little in the way of example code/support docs to start with so I am hesitant.
Here is my url to __utm.gif broken up over the lines for clarity:
utm.gif?utmac=MO-xxx31982-1">http://www.google-analytics.com/_utm.gif?utmac=MO-xxx31982-1
&utmhn=myfake.com
&utmcc=_utma%3D7042858245.1436153422.1214501708.1340117181.1340117181.1%3B%2B_utmz%3D1.1340117181.1.1.utmcsr%3D%28direct%29%7Cutmccn%3D%28direct%29%7Cutmcmd%3D%28none%29%3B
&utmwv=1
&utmr=click
&utm_source=Emails
&utm_medium=Newsletter
&utm_campaign=tet+2012-06-19+10%3A41%3A30
&utmp=%2FMYZZ%2FNEWSLETTERS
&uservar=16430
Does the utmhn need to be a legit URL or one associated with the account? What about utmr? I was using that to contain 'click' or 'open' so I could differentiate.
When I click a link in the newsletter I get the expected pixel image returned so Google is getting something anyway even if ignoring my querystring. In my Google Analytics account where should I see the data relating the the __utm.gif hits? So far I see none when using this technique.
P.S. I got this technique from here
Follow up:
I changed a few things and my url now looks like so:
utm.gif?utmwv=1">http://www.google-analytics.com/_utm.gif?utmwv=1
&utmn=8391432847
&utmsr=click
&utmsc=-
&utmul=-
&utmje=0
&utmfl=-
&utmdt=-
&utmhn=myfake.com
&utm_source=my_newsletter
&utm_medium=Emails
&utm_campaign=tet 2012-06-19 10:41:30
&utmr=my_newsletter
&utmp=images/google/click
&utmac=MO-xxx31982-1
&utmcc=_utma%3D24820632.1925394567.1340121629.1340121629.1340121629.2%3B%2B_utmb%3D24820632%3B%2B_utmc%3D24820632%3B%2B_utmz%3D24820632.1340121629.2.2.utmccn%3D(direct)%7Cutmcsr%3D(direct)%7Cutmcmd%3D(none)%3B%2B__utmv%3D24820632.6430%3B
and nothing happens except when I paste that link into my browser then Google gets it, so why does it not work when called from the PHP line $handle = fopen ($urchinUrl1, "r");?
ok, nevermind. I changed my app around so the utm.gif is just included in the email and in a redirect page rather than called from the script. Should have done it that way but got caught up in the fancier idea of calling the url from php.
Even though this question is over a year old...the GA measurement protocol can be used to send hits back to GA for newsletter opens and clickthroughs.
To answer your initial question, it looks like you're missing the utmhid and utmn parameters.