Adobe Analytics DTM - Prevent initial server call on specific pages/subdomains? - javascript

I'm using Adobe DTM. What I'm trying to figure out is the best way to prevent the initial page load server call from going out on specific pages. The reason is, many parts of our website are 3rd party integrations separated by subdomains. Some of these 3rd party sites are Single Page Applications (SPA). Since most of our site is not a SPA, I need to figure out how to stop the initial server call when I hit one of these subdomains? The vendor is updating the s.pageName variable mapping on their end so I need to prevent the initial call from firing or I'll get two calls initially. I have a data element and event-based rule set-up to detect a change in the page name. I just need to stop it the first time.
Thanks!

In DTM, to prevent that default beacon on page load, you need to put a "return false" statement for those urls somewhere in your Adobe tool code. http://www.digitaldatatactics.com/examples/DCRsuppress.html has an example.

Related

Limit the number of times my code is loaded on a web page based on geo targeting - javascript

I have a problem.
I have a piece of code, that I send to websites to be placed inside the <head></head> right at the very beginning of the header. My code will run and collect some data and pass the result to the rest of the page (ad servers, forms, etc., for example).
My problem is that I need to limit the number of times this code can make calls back to my server and that needs to be based on user location (city, more specifically). I cannot use the ad server, and benefit from its targeting capabilities because I do need to run this code before everything else.
I was thinking if there was any sort of script that would allow me to identify the user location and make the decision to whether or not to call my server, therefore making sure that I am only using my resources when it is actually needed.
I thought about using the html5 geolocation API but it requires user interaction. Then I was thinking about using a service like IpRegistry.co, to:
query for the location and if ;
location=desired location;
then load javascript code;
otherwise do nothing;
I am not sure if this is possible and how to do it. Any help would be greatly appreciated and desired. I am ready to explore opportunities here.
If I didn't stress enough, it needs to happen inside the header, not on the body.
Thanks in advance.
PC

Mean Stack Application: Page does not rerender on refresh, but returns only JSON

I'm currently designing a MEAN.js web application, and for some reason, whenever I refresh the page on a route or window.reload, it does not rerender the page, but only returns the JSON file found at that current route.
For example, when I'm at localhost:8080/people:
If I click here from the main page, I get
But if I hit refresh or reload the page for whatever reason I get
Does anyone have any idea why this is happening and how to fix it?
Presumably you are using what Angular call's html5Mode routing.
This uses pushState and friends. These are browser features designed to allow you to build a web app which has what appear to be separate pages with unique, real URLs but when you change the page you actually modify the DOM of the current page (to State B) instead of loading a new one from scratch.
The design intention for pushState and friends is that if you request the unique, real URL that maps onto State B then the server will provide the browser with the HTML for State B directly.
This means that:
if you arrive on the site without going to the homepage first, then you
load the content you are trying to load directly (which is faster than loading the homepage and then modifying it with JavaScript).
if you arrive on the site without JavaScript working (which could be for many reasons, then everything still works. See also Progressive Enhancement and Unobtrusive JavaScript.
What you've done wrong is that your URLs are mapping onto your JSON based API instead of server side processes that generate the pages.
You need to write the server side processes. You could consider using the Accept header to allow them to share URLs with the API (so the server returns either JSON or HTML depending on what the client says it accepts).

Access Google Apps Scripts from an external site

I currently have a website that automates Instagram actions: http://instapromobiz.com. It is almost all javascript based, with some php to post to databases. Users login and an entry is created in a mySQL database, containing their username and how many credits they have (1 credit = 1 action). Then users add tags and press start, then the javascript makes requests via Instagrams API, and ajax+php is used to update their database.
The issue is that when the user leaves the page, or even refreshes it, the script will stop. Otherwise it will run forever.
I have a javascript file that contains all the functions needed to run the script until the user stops it.
My question is, can I use Google Apps Scripts to host this .js file so that when the user leaves the page the script continues to run. I've uploaded the code and published it, but I can't figure out how to access it from an external website.
node.js is out of the question, and I'd rather not convert the whole site to php(I don't know php well) and a cron wont work because of all the javascript.
Any help would be great, thanks!
Apps Script is going to be limited to a 5 minute execution time. You could create time based triggers to contend with that functionality to some extent, but the script will stop 5 minutes after being invoked.
If you still think Apps Script is a good fit, you would just need to deploy your script as a web app, and utilize a doGet(event) function or a doPost(event) function to receive the request from your external application. If you need to return content, there is ContentService to help facilitate that part of the process.
To maintain the different data points for each user, you will need to utilize ProertiesService.getUserProperties(), to store persistent string values for each user.
The other part of Apps Script that may come into play with your Javascript, is that Apps Script uses caja sanitization for javascript (just something to be mindful of, if you run into issues).
If you MUST defeat the execution time problem in google apps script. You can monitor the execution time and at a certain point before time expires invoke the script recursively and pass it the parameter of wherever it left off.

Get parameter from another page using javascript?

I have a wordpress site, and i'm not a php developer and not very eager to start either so I'm avoiding it like the plague, but I do have a requirement that requires a little bit of extra coding. I need to:
go to a different website,
download that page,
check for a certain phrase,
if phrase exists, extract a link from that page
and if link is returned I need to show that link on my wordpress site.
Currently, I have an asp.net page that does this and i'm hosting that page in an iframe on my wordpress site. but i'd like to do it without an iframe.
Question is, is there anyway for javascript to go to a different page (my asp.net page) and get a parameter (link) from it. If link is provided i will show certain content on wordpress site.
Or can javascript download a text file from the server? problem with that is i need a trigger to update the text file.
Any advice is appreciated.
Thanks.
What you should understand is that by "avoiding [PHP] like the plague" you're inadvertently avoiding the proper way of doing things. Javascript is a client-side language, and PHP is a server-side language. By asserting that you only want the load on the client's end (the kind of logic involved in what you want to do isn't exactly lightweight), you can potentially end up with a VERY slow webpage.
Not to mention, this type of situation is analogous to using a hammer to do a backhoe's job.
Either way, to answer your question, yes. You can use the jQuery Load method in tandem with Javascript's Match method.
What you should TRY to do, however, is make a CURL request using PHP, and then cache the page on your server. By doing this, you will limit the number of calls to a given page, and optimize load times.
Please consider the second option, even as an attempt in good practice. Good luck.
Use ajax and connect to a different page (on your server) which is written in server-sided language (like asp.net, as you said), that connects to the remote website.
More about Ajax

Most Efficient Way to Count Clicks

I'm starting to run a few ads on a website, and I'm trying to decide the best way to track performance.
Specifically,
What's the most efficient way to count clicks? About the only way I can think of is to link the ad to another page with the ID of the ad as an argument (e.g. adserver.aspx?id=1234). The other page would then update the database and do a redirect to the advertiser's link. However, it seems inefficient to have to load a separate page for this. Are there any other options?
Also, it seems like I might need to know stuff like how many clicks occurred in a given week. But storing a separate database row with a date for every single click seems excessive. Has anyone else done something like this? Would it make sense to maybe create a new row for each week and increment a counter for all clicks that occurred that week?
Any tips appreciated.
I would suggest that your first solution is the best option, in fact it is the design that most similar systems (OpenX, Google AdSense etc) employ. Additionally it helps you better managed your banners and prevents your site leaking search engine spiders.
As for performance that is just a question of having a good design, in a typical design the redirection script will be fairly lightweight so should process requests fairly quickly. It is worth mentioning that you could thread off the DB updates to reduce the redirect request response times.
There is of course another option:
Rather than homebrew your own banner serving scripts look into implementing OpenX instead, it is free and an extremely good piece of software. OpenX can be found here:
http://openx.org/
and here for the open source version you can run on your own server:
http://www.openx.org/publisher/open-source-ad-server
Another option would be to implement something like Google AdSense and save yourself the hassle of finding advertisers etc. Google also provides tools to allow you to sell banner space and then fallback to default AdSense banners if you have no active advertisers (OpenX will also do this and also support integrating AdSense (and other advertisers))
You can do it with JavaScript.
Opening the page:
Send the ad URL to the client
When the user clicks the ad, use JavaScript to open the URL. Or, simply use an anchor with target="_blank".
Logging the click:
Either way, hook a JavaScript function to the ad click event.
When the user clicks the ad, use AJAX to call a web service. The web service will then log the click.
This way the ad opens as soon as possible, then the browser asynchronously communicates with the server for logging.
The question is, what happens if the user clicks the ad, the page opens, then the web service call fails? If you would prefer, you could call the web service first, then and only if the call succeeds, open the ad. Probably not the best from the end user's perspective.
For you question #2: Storing each click gives you the most reporting flexibility later. If you are set on weekly reports, why not set up a weekly process that generates the reports you need, then cleans up the data? You could even skip cleaning up the data for now until space or speed becomes an issue.
Would it make sense to maybe create a new row for each week and increment a counter for all clicks that occurred that week? Probably not. Only one process can update the counter at a time, otherwise you'll lose data. The locking that has to occur to get the value then update it will probably significantly slow down.

Categories

Resources