Cross-device cookie tracking with Universal Analytics? - cookies

Is it possible to set a cookie (for my domain) that is tied to a certain user across devices, somehow using the cross-device capabilities of Universal Analytics?
I don't need to know who that user is, just that it's the same person on a different device.
I know I can use Custom Dimensions (formerly Custom Variables) to assign an arbitrary value to a user/session but I need to be able to read it's value. It's a boolean value I need to store so even the fact it exists would be enough.
I hope I've explained clearly but if not let me know!

Related

Best Practice Using Django Signal (For user authentication?)

I am new to Django and want to know deeper about the concept of signals.
I know how it works but really don't understand when should one really use it.
From the doc it says 'They’re especially useful when many pieces of code may be interested in the same events.'
What are some real applications that use signals for its advantage?
e.x. I'm trying to make a phone verification after user signup. Because it can be integrated inside the single app and the event that interested for the signal is only this 'verify' function, therefore I don't really need signal. I can just pass the information from one view to the other, rather than using pre_save signal from the registration.
I'm sorry if my question is kind of basic. But I really want to know some insight what is the real application, in which many codes interested in one particular event and what are some trade off in my application.
Thanks!!
Often signals is used when you need to do some database-specific low-level stuff. For example, if you use ElasticSearch for better searching documents on your site, you may want to automatically update search indexes, when new document is created or old one was edited.
Also you may have some complex logic of managing database objects. For example, you may need some specific logic of deleting object. For example, when user is deleted, you may want change all the links to his profile by some placeholder, or when new message is created or other action is performed by user, you want to update "last visited" field in user's profile and there's no direct relation between this action and updating the profile.
But when you're just implementing business-logic as in your example with verification, you don't need to use signals, because you don't need any universal logic related to deleting/creating/editing any object: you have a certain object with which you work and can do stuff directly.

Store Total Steps count in Request or Application scope?

I'm creating a multi-step form with pagination that will show a Next and Previous button depending on which step you are on. In order to display the buttons correctly, I need to store the total number of steps in a variable somewhere.
Do I store this in the Request scope e.g. REQUEST.TotalSteps = 5 or Application scope e.g. APPLICATION.TotalSteps = 5? The number of steps will rarely change so I'm thinking that Application scope is better suited, but I want to minimize the use of RAM because I have a lot of stuff stored in the SESSION scope for each other.
What would be the ideal option?
Depends on how you're gonna be using it really, and what framework you're using, how you're architecting your app and all that sort of thing. You only need the value in memory during the request(s) that need it, so TBH I'd just put it in the variables scope, making sure that the code that sets that variable is loaded for the requests that need it.
You'd not want to put it in session because it's not value specific to the visitor, nor does it have any relevance to the session: it's all just about that form.
Similarly it would not belong in the application scope (well: that has caveats, but given the low level of detail you give us as to how you've built you're app, let's assume this to be the case) because - again - it's not something the entire app needs; just the pages actually interested in how many pages that form has.
If you can give us more information regarding your architecture, I can possibly fine-tune this answer, but based on the info given: this is pretty much how you need to approach it, all things being equal.
The session scope is used to store information for the specific user. The application scope is used to store information that is available to the entire application. The request scope stores information during the course of the request. You want SESSION scope.

Magento communicating with another system

I'm building a magento (1.9CE) store which needs to interface with another system and I could use some guidance.
Although not particularly relevant, I'm communicating with the 'other' system using web services (it's on another server) but what I need help with is finding the places where I need to put in code to do what I want.
There are three major functions that I need to implement:-
When a user clicks on the product detail page I need to make a call to check the stock levels on the other system, update the magento stock levels and THEN display the product detail page.
When a sale is completed, I need to send details of that sale to the other system.
When a new product is added I need to communicate with the other system. This may be a bit more complex because there are a few checks I need to do during the 'add product' process, for example, check the SKU is valid, that tghe product doesn't already exists, etc. I think until I start coding this I shan't realise the full extent of this functionality!
Any guidance gratefully received!
Even though this might (and probably will) dramatically slow down your store, if you want real-time information, I guess the easiest way would be with observers.
You can use catalog_controller_product_init_before: This will trigger when the product detail page is starting loading, so you should be able to upload the stock at this point, before the page has finished loading, so that if there is no stock it will not be buyable, which I guess that's what you want.
You can use sales_order_place_after: This will be triggered after a new order has been placed and saved in the database.
You can use catalog_product_new_action or catalog_product_save_after: Depending on how you create your products the first one might not be triggered. The second one will always be triggered once a product (new or existing) has been saved, so at this point you will need to check if the product is new or existing, and do your stuff depending on that.
For an example of how to create an extension and usage of observer events, check this out.
I hope it helps!

Saving locations using Google Maps without violating T&Cs

I am currently working on an app (not live yet) that will allow users to create projects and set the location of each.
I originally added an autocomplete field that worked with the Google maps lookup to help the user type in the location and also it would find the latitude and longitude of the place/location and show it on a map.
At this point I was saving the location, latitude and longitude to database fields.
This made the user experience quite straight forward.
However, I now think this idea of storing the autocompleted location violates 10.1.3 of Google Maps T&Cs.
I need to include the locations in my list page and Google allows short term caching for performance purposes but surely that would mean I would need to update the cache or something for each entry at least every 30 days which isn't really an option.
This would also mean that the location data belongs to Google which limits any future use of this data (an API on my site for instance).
I wondered if it would be an option to use openstreetmap data to get the full location (although I'm not sure if it can be used to provide an autocomplete facility) and then pass that to the google maps lookup so that the location provided by the openstreetmap autocomplete with looser restrictions can be saved to the database. However, even if that was all possible it could be confusing for the user if the openstreetmap autocomplete failed to find a location/place that exists on google or it was labelled differently.
I'm not sure if that's an option or not.
I am currently tending towards a plain text box with an example location shown alongside it so the user can see the extent that the location needs to be typed (ie a full address) so that when it is used to lookup the location via Google it will bring back the correct latitude and longitude but will also be informative to users when they see it on the list page.
This does mean that the location field content is ok to store in the database then but it puts more reliance on the user typing the address in correctly and if they don't type it in properly the auto lookup may fail to locate it and/or it may not be viewer-friendly on the list page.
Can anyone offer any better ways that I could help users to type in an accurate location (which could be a place with address or just an address) so that it doesn't violate the terms and conditions and allows my site to have ownership of the location?
Thanks

What is the best way to check if a given userprofile is active or deleted in C++?

I have a list of usernames. In C++ which way would it be better to check if the profile associated with the username exists or deleted in the local machine? I came across ATL CAccessToken class methods and Win32 APIs with GetTokenInformation etc. Which one would be better on performance perspective too?
I would expect that performance-wise a single call to gather the entire list of all users would be faster than verifying them individually. You can do that using the NetUserEnum function as described here. This will also get you the status flags so you know if the user account has been disabled, locked out, their password expired, etc.