Is there any CKAN extension for Google Tag Manager? - pylons

I want to add my Google Tag Manager script to my CKAN-2.4 instance. I can manually add it by changing the template, but I want to keep it separate from CKAN code, so I was thinking separate extension is better. I searched for the extension, but I did not find anything. Can anybody tell me better approach of adding Google Tag Manager script (extension, changing template or anything else)?

Extension is the way to go, and it's easy to start.
Would be awesome if you add schema.org tags for dataset and datacatalog and DataDownload.
And once you open-source it ;), will be sure to catalog it on extensions.ckan.org.
Making judicious use of {% ckan_extends %} and {% block %} should allow you to create a Google Tag Manager extension that's readily usable in other CKAN instances.

Related

Can I Use Google Tag Manager in Electron?

I am trying to integrate Google Tag Manager into an Electron app,
but it doesn't seem to be working. it seems like gtm codes I planted in the app are NOT sending the analytics data anywhere.
I found this issue on Electron github repo. Seems like some people are having the same issue.
I wonder if it's impossible at all to integrate GTM on Electron, or is there any way around to do this?
[Update]
While reading Alexander Leithner's answer, a further question popped up.
on Google Tag Manager - Dev Guide - Security, it says:
While most of the tag templates in Google Tag Manager are also
protocol relative, it's important to make sure that, when setting up
custom tags to fire on secure pages, those tags are also either
protocol relative or secure.
Does file:// protocol matters because GTM is protocol relative? Wouldn't it be possible to bypass this with GA's forceSSL=true option which can be set on GTM Interface?
[Final Update]
I found the perfect answer in this blog post:
Run Google Tag Manager And Google Analytics In Local Files.
Thank you Eike Pierstorff, for giving me the hint of setting storage to none, it led me to this post.
GTM by default used to use the same protocol as the webpage - that's what "protocol relative" means. I.e. there is a bit of code that loads the GTM library, and if this uses the file protocol (as per the embedded wegpage) it will try to load the library as a file, which does not work. However GTM has switched from protocol relative to https by default, so I don't think GTM is your problem here.
You mention Analytics data, and if this refers to Google Analytics then your problem is not with GTM, it is that GA does not work on local files. Google Analytics uses a cookie to store the clientId (which is needed to aggregate individual hits into sessions/users), and since you cannot set cookies on a local file this does not work.
A possible workaround would be to go to your GA tag in GTM, to the "set fields" settings, set "storage" to "none" (which means that no cookie is set) and pass in a clientId manually.
As this comment by Samuel Attard (MarshallOfSound), who is an Electron developer, states that Google Tag Manager does not work when the including webpage is loaded using a file:// URL.
If you'd instead load your application via http:// (or more preferably via https://), you would be able to use Google Tag Manager.

How to properly format an image url in a Vue.js single-file-component?

After about a week of tinkering, I have managed to introduce webpack and Vue.js single file components into my existing Orchard (ASP.NET) module.
Now I've unexpectedly hit a snag, and for the life of me, I'm stumped. I have several image resources that are part of my custom Orchard theme, which is a separate module (*.csproj) within my Orchard solution.
So (at the risk of demonstrating my woefully inadequate understanding of URL concatenation in web projects) I innocently add this line to my Vue.js single file component:
<img src="~/Themes/MyOrchardTheme.Theme/Images/AnImage.png">
Now when webpack tries to process this and bundle my component I get this error:
Can't resolve 'Themes/MyOrchardTheme.Theme/Images/AnImage.png' in 'redacted' C:\Projects\Orchard\Modules\redacted\Module not found
This kind of makes sense, because the layout of my projects and resources locally and the layout after deployment to Azure obviously differ.
So what is the right way to specify the url for my image as it will exist at runtime on the server, without specifically testing for it's existence when transpiling with webpack?
I'm not going to accept this as the answer, in case someone can offer something better, but after some tinkering I was able to solve my problem by using this:
<img :src="theimage" />
and adding a computed property like this:
computed: {
theimage: function () {
return '/Themes/MyOrchardTheme.Theme/Images/AnImage.png';
}
This will bypass the Webpack transpiler (or vue-loader or whatever) check to make sure the resource can be located and has the added benefit that I can programmatically control the image displayed, which (although not mentioned) is ultimately what I wanted to do (code not shown). I was expecting to use v-if or v-show with multiple image tags, but using a computed property killed two birds with one stone.
Thanks to everyone who provided feedback. - I have a great deal to learn!

NopCommerce Plugin Localization

I am working on a NopCommerce website and have quite a bit of site-wide customization so I have created a plugin to handle it all but not sure on how to handle the localization. I see there are a couple of ways of updating the Localization strings, one way I have found is in the Plugin's Install() method:
this.AddOrUpdatePluginLocaleResource("Plugins.Payments.PayPalStandard.Fields.AdditionalFee", "Additional fee");
This looks like it only adds new resource strings for the plugin, is there a similar way to update the other resources via the Install() method like:
Admin.Catalog.Products.List.DownloadPDF
I found that there is a way to export the entire language to a language_pack.xml file, would it be better to just create an entire language pack instead? Is there a way to add a new language pack from the plugins Install() method?
I guess I could simply open the language_pack.xml file and add each resource found using the AddOrUpdatePluginLocaleResource, I was hoping that there was a built-in way of doing this using NopCommernce functionality.
Thanks!
As #Raphael suggested in a comment, provide a language pack along with plugin file to the end users, and give an option to upload required resource file within your plugin configuration page.
As per as I know, there is no inbuilt way to add language pack on plugin installation, but you can do some code on plugin install method to find language pack file(s) from plugin folder and install it, not quite sure, you can take reference of inbuilt methods.

Adobe DTM header for a library download

Background: My company is starting a proof of concept for adobe DTM and I am starting to familiarize myself with it. We have many different domains and many different internal sections that all may want to use different libraries on different pages. We are using the library download setup in DTM. I've watched a lot of the tutorials the tool and have read all of the documentation that I could find on the headers.
Issue: I believe that the libraries are all created with the DTM tool. For instance, if we create a rule, or add 3rd party javascript to DTM, then that would be placed in the library. Because of the way that the team has generally thought about js libraries before, where we upload them ourselves, most of the team believes that we can physically place the 3rd party js libraries in the location designated by the header and that we can reference them with an include() call in the Javascript/Third Party Tags section of a rule. I don't believe this is possible. Is there anyone who can shed some light on this?
Thanks for your time,
Mike
(I already answered this at the Adobe Forums, but I thought I would include the reply here for others looking at stack exchange)
I could be wrong in my assumptions, but I have always understood this method as a way to simply host DTM functionality on your own servers for downtime/uptime/SLA reasons. :) Meaning, you would want to go with this option simply because you need to ensure that DTM embed urls/scripts never ever go down and that they are lightning fast and never give you issues. :) You would then use the script loading capabilities by configuring the DTM UI to load the 3rd party scripts or custom built scripts through rules. You would load them either on pageLoad top or bottom, domReady, or onLoad. There is more documentation on this option here and some reasons why you would use that option:
http://microsite.omniture.com/t2/help/en_US/dtm/hosting.html
http://microsite.omniture.com/t2/help/en_US/dtm/deployment_download.html
However, you can also include these scrips just like you would with any other javascript reference like you mentioned above. The trick would be just figuring out the url to include as your src attribute. DTM itself has an API that you can use to load scripts, and it also includes a "settings" property and "configurationSettings" property that you can use to find a lot of those scripts that you are interested in loading. See all _satellite object documentation here:
http://microsite.omniture.com/t2/help/en_US/dtm/object_reference.pdf
In more detail, you could do something like this to get your script path dynamically after DTM embed scripts have loaded:
var scriptSrc = "//domainOfHost.com/" + _satellite.settings.scriptDir + "scriptSrc.js";
Then you could use this function on the _satellite object to load the script you are interested in:
_satellite.loadScript: function (url, callback)
PARAMETERS:
url: the URL of the script
callback(optional): the function to be called after the script has loaded.
DESCRIPTION: Load an external script.
Thanks,
Ben

Why is WSCript object not known to my script that's controlled by a custom IScriptControl?

I am using someone else's library that provides its own scripting host instance, it appears.
This lib provides me with functions to define the type of scripting language such as "jscript" and "vbscript", and I can supply it with script code and have that executed, with passing arguments in and back. So, basically, it works.
However, when I try to access the "WScript" object, I get an exception saying that this keyword is undefined.
The developer, not knowing much about this either (he only made this lib for me because I do not want to deal with Windows SDKs right now), told me that he is using "IScriptControl" for this.
Oh, and the lib also provides flags to allow "only safe subset" and "allow UI", which I set to false and true, respectively.
Does that ring a bell with anyone? Do a user of IScriptControl have to take extra steps in order to make a WScript object available? Or, can he use IScriptControl in a way that this is supplied automatically, just as when running the same script from wscript.exe?
Basically, all I need is the WScript.CreateObject function in order to access another app's API via COM.
I don't know why WScript is not known, but I suspect it is because the script host doesn't provide it. Maybe only wscript.exe does this.
If you are using Javascript, to create an object you can use new ActiveXObject(). If you are using VBScript, you can just use CreateObject.
See this article for some background.

Resources