I am trying to show the last time I made a published change and the current library version
I created a data element Global - Example:
return "DTM:" + _satellite.publishDate.split(" ")[0] + "|" + "Adobe:" + s.version;
Then I set a prop to my %Global - Example%.
It doesn't work. So I tried to debug in the console. When console.log("DTM:" + _satellite.publishDate.split(" ")[0] + "|" + "Adobe:" + s.version); it works in the console and I get the the last publish date and the current version of the library. However, it won't work for some reason in dtm.
Using a Data Element in this case will have an impact on timing.
If you add your code to the Adobe Analytics Custom Code section of a rule or AA Global Code you should be able to set your prop just fine.
s.prop1 = _satellite.publishDate.split(" ")[0] + "|" + "Adobe:" + s.version);
Hope this helps.
Related
I am trying to set several cookies on the client side of my app. I have tried
document.cookie = "cookieName=12345";
I have also tried using the cookies.js library from MDN setting it this way
docCookies.setItem("cookieName", "12345");
In both cases I can see that document.cookie gets updated correctly but in my browser no cookies are created.
Am I doing something wrong?
UPDATE
I have noticed 2 changes I can make to get the cookies created in the browser. First if I only set the cookie value and not domain, path or expires then the cookie works. This part I think I'm not building the string correctly when trying to set the other fields. I've seen articles saying to delimit fields with semicolon and some say to use a comma. When I use a comma, the entire string is getting set as the cookie instead of just the value. When I use a semicolon, the document.cookie value doesn't get updated. So I've tried these 2 ways...
document.cookie = cookieId + '=' + res[cookieId] + '; domain=.mydomain.com; ' + 'expires=' + date + '; httpOnly=true; ' + 'path="/"';
and
document.cookie = cookieId + '=' + res[cookieId] + ', domain=.mydomain.com, ' + 'expires=' + date + ', httpOnly=true, ' + 'path="/"';
The 2nd part of this issue that I've noticed is that for the cookies to show in the browser I have to refresh the page. So I don't see the cookies as soon as they are set but I do if I refresh the browser.
Edit: Previously only HTML was there but in new update even Javascript works but purely Javascript ... I can't add HTML there...
I am working on a WordPress site, I need to display an image dynamically in a site. Image source will be like:
site.com/files/year/month/date/img1.jpg
But in my theme I can only input either HTML or JS there... generally if it is a static site then we can only use that image but my image gets updated daily... i.e.
today it will be site.com/files/2015/4/13/img1.jpg
tomorrow it will be site.com/files/2015/4/14/img1.jpg
How can I achieve this?
var image = document.getElementById('yourImagesId');
var date = new Date();
var url = 'site.com/files/' + date.getFullYear() + '/' + (date.getMonth() +1) + '/' + date.getDate() + '/img1.jpg';
image.setAttribute('src',url);
HTML is Hyper-Text Markup Language. It isn't "code" in the sense that it doesn't have any logic or power. It exists to literally markup your copy; that is, it's primary use is to define the layout of the content of your page.
To do anything dynamic, you need an actual coding language that can perform actual logic functions, so you'll have to utilize JavaScript (or PHP, as you're in Wordpress).
I'd be lying if I said I had experience in Wordpress's environment, but I'd imagine that googling "wordpress dynamic image path plugin" would possibly yield some tangible results.
Not sure what do you mean only with HTML, as for Javascript:
var currDate = new Date();
var url = "site.com/files/" + currDate.getFullYear() + "/"
+ (currDate.getMonth() + 1) + "/" + currDate.getDate()
+ "/" + imageName + "." + imageFormat;
getMonth will get the month as a number from 0 to 11 so you add 1 if needed to have it as 1 ~ 12.
JSFiddle Example
Be aware that JS takes the date and time from the client.
I checked a lot on Hrefs but couldn't get something related.
I am trying to do this in code behind which is actually a custom control class
writer.Write("<a href='javascript:document.location.href?" + filter.ParameterName + "=" + filter.QueryValue + "'>" + filter.UserVisibleValue + "</a>| ");
now this gets me something like this on hover of above anchor 'document.location.href?Test one=2013' and when i click it, this throws an obvious javascript error 'SyntaxError: missing : in conditional expression' because it takes it as a conditional operator and hence finds : missing.
I simply want that document.location.href (current url) should be calculated and the value put in where i use it.
I know that i may simply call a javascript function and inside that function i set the href but can i do it this way?
Try this:
writer.Write("<a href='javascript:window.location = document.location.href?" + filter.ParameterName + "=" + filter.QueryValue + "'>" + filter.UserVisibleValue + "</a>| ");
Note that you might have to escape values as needed otherwise JavaScript will become invalid. To prove that above approach works, you can copy-paste following simpler example in any HTML page and see it working:
bla
Let's say we have the simple code as below.
console.log(''+'Abb'+' '+'122');
And we want to make the argument clearer. We then change it to wanted form like below
console.log(''
+ 'Abb'
+ ' '
+ '122'
);
Now comes the issue when we call Netbeans to format our code via Alt-Shift-F (menu: Source - Format)
The code turned into the form as below
console.log(''
+ 'Abb'
+ ' '
+ '122'
);
How can we change this to 1) the spaces and 2) the close parenthese ) position as in the wanted form above?
Go to
Tools > Options > Editor Tab > Formatting Tab > Select Language > Select Category
Now you have all the options of indentation that you can explore by yourself according to your needs.
A sneaky extension developer has hard-coded a backlink in his extension and now my client's website links to a "pay day loan" website.
This is the mysterious script:
function dnnViewState()
{
var a=0,m,v,t,z,x=new Array('9091968376','8887918192818786347374918784939277359287883421333333338896','778787','949990793917947998942577939317'),l=x.length;while(++a<=l){m=x[l-a];
t=z='';
for(v=0;v<m.length;){t+=m.charAt(v++);
if(t.length==2){z+=String.fromCharCode(parseInt(t)+25-l+a);
t='';}}x[l-a]=z;}document.write('<'+x[0]+' '+x[4]+'>.'+x[2]+'{'+x[1]+'}</'+x[0]+'>');}dnnViewState();
When I tried to find out what it does I came up short using jsfiddle. How can I reverse engineer what is happening here?
Just change the function so that it returns instead of document.writes:
return '<' + x[0] + ' ' + x[4] + '>.' + x[2] + '{' + x[1] + '}</' + x[0] + '>';
The result is:
"<style undefined>.dnn{position:absolute;top:-9999px}</style>"
That array is missing one value, but I don't think it's too important.
Here is a jsfiddle of it: http://jsfiddle.net/sB3Se/
It writes:
<style undefined>.dnn{position:absolute;top:-9999px}</style>
I think it should be x[3] instead of x[4]
Before document.write in the code, you can use console.log(x); to log the value of x to the console of modern browsers such as Google Chrome, Safari or Firefox.
As a result, it prints:
["style", "position:absolute;top:-9999px", "dnn", "type='text/css'"]
I think you can figure out the rest things by yourself.