Links to custom content type in Magnolia CMS - magnolia

I created a custom content type for events and I can list the active events in a page with their summary.
I want to create a details page for every event, currently the generated link for every event points to the event name as if it is a separate page. How can I have a page called view-event that will capture the event name and display its content
<ul>
[#assign events = cmsfn.contentByPath("/", "events") ]
[#list cmsfn.children(events, "ev:event") as event ]
[#assign active = event.isActive!false]
[#if active]
<li>${event.name} - details</li>
[/#if]
[/#list]
</ul>

I don't think it works that way. If you want to link to a page showing the event, you have to have create such page. You can then pass the event that page should show via either selector or as virtual subpage or via request parameter. See for example how in travel demo tours or destinations are shown. It's the same concept.
In Travel demo, content lives in custom type (tour or destination respectively). However if you open pages app, you will see that under /travel website, there's one page for tours (/travel/tour) and one for destinations (/travel/destination). In the demo, selectors are used to pass info about what tour or destination you want to display. You can see that by observing the top level navigation and see that it points to /travel/tour~active~.html, where the part between ~ is the selector that page template of tour page then uses to resolve concrete piece of content to show.
You could build the same using virtual subpages and virtual uri mapping, but in the end there needs to be a page template and associated page that understands the info you are passing in and how to render the custom content type. Passing just link to the custom content type item will not render the page.
Alternatively, if you develop SPA, you can also request custom content type over delivery endpoint and get it in form of JSON, but then it's your SPA that is responsible for rendering that JSON as html for the browser to present to the user.
In the element that you have pasted in your question, you can list all the events and their details directly. But if you want to point to the details of the event via hyperlink as you are trying to do and have that page to show the content you need to create the page and the template. For example, create page called /view-event in your website tree. Create template called view-event and assign it to the page. Then change the snippet above in your event-overview page to link to the view-event to look like details. That way you get event name (or id or what you need) passed to the view-event page and be able to retrieve it there via state.selector and with that have view-event page render what is needed. More on that in Magnolia Documentation

Related

Google tag manager single page application window load and history change

I'm trying to create page view tags. I have to create two for two different triggers.
Page view triggered by history change;
Page view triggered on window load (because first page load doesn't have any history change)
My problem is the home page, which is firing both tags.
Because if put in URL www.mysite.com, the page redirects to my.site.com/home
which creates a window load and a history change. So two page view tags are fired.
I can't exclude historychange trigger to exclude page path: /home because once people got into the site they'll navigate back and forth.
I can't exclude windowload because people may use either URL to enter the site (mysite.com or mystie.com/home)
Anyone can help me with this?
I suggest to create 1 page view tag instead of 2 and use both triggers. Multiple triggers in GTM tag work with OR operator. And set tag to fire once per page.
Advanced settings -> Tag firing options -> Once per page
UPD I'm afraid that in this case other hits for virtual pages triggered by History change will not be fired (because of 1 per page rule). Try to check what value have variable Old History Change after redirection. If undefined or empty, you can use it in trigger of History Change tag as exclusion.

GTM Registering click without changing page

I have setup DFP to return a list of Custom Creatives. Each of these creavtives contains the following HTML:
<a href='%%CLICK_URL_UNESC%%' class='drop-down-ad'>Ad Link Text</a>
When these creatives are rendered to the page I have some JavaScript that finds all the anchor tags containing the class drop-down-ad and grabs the src attribute and stops the page from changing when clicked and loads content in via ajax. I do not want the page to change but I would like to still tell DFP that the user click the link. I am not sure if this functionality is supported by DFP?
Is making a request to the generated CLICK_URL_UNESC using ajax supported by DFP? Or is this not a thing I should be doing.
Hopefully I have explained what I am trying to do ok. Let me know if you have any questions.

How to trigger an event tag when a user leaves a page?

In Google Tag Manager, I'm tracking the pageScrollDepth variable.
I want to trigger a Google Analytics event Tag that pushes (as custom metrics) the recent value of pageScrollDepth just before the user leaves the page.
How can I create the leavingPage trigger?
http://www.blastam.com/blog/index.php/2014/04/scroll-depth-tracking-analysis-google-analytics
^ The code in this blog post is the one that your are looking for where it takes the last scroll depth before the user leaves to another page. You will find a link to bitbucket to download the code
Paste the code in a Custom HTML tag and then create a JS variable to call the "callbackData.scrollPercent" for the Event Label

Multiple Pages/Views with Same URL, only fire tag on one of them

I have a page that uses a MultiView in ASP.NET to hide and show page elements, rather than going to different pages. The same URL is maintained through all of these pages. If I want a tag to fire on, say, the third view in this process, how can I specify this to Google Tag Manager as a rule without having a URL change to base it on? I know there are other options besides URL, but I haven't seen any that would work in this case...
The solution I went with was to add some sort of variable indicating the page I'm on. For example, if my page was called thirdPage, then I add to the data layer:
dataLayer = [{ 'pageTitle': 'thirdPage' }];
and check for this in my tag triggers in Google Tag Manager.

Google Tag Manager Custom Events Capture Specific Page

I'm tracking multiple domains/subdomains (domain1.com, domain2.com and sub.domain1.com) with Google Tag Manager/universal analytics.
I created a Custom Tag Event (in GTM) that fires on ALL of those pages.
Is there a way to capture the specific page where that event was fired from?
For example, I have an event that fires when a user hovers over a specific <div> element. This occurs on both domain1.com, domain2.com and sub.domain1.com.
When those events fire, can I send the specific domain to GA's event catogory/action/label tags?
some suggestions:
1) You should already be able to break down an event dimension by pages or visa versa (e.g. go to the event report and add pages as 2ndary dimension. Or go to the page you want to see and put event category/action/label as 2ndary dimension). You could also create a segment based on page name. Of course, using the page names may not be useful if you are getting the default relative url (no domain). It is common for people to create a filter that adds domain prefix when spanning multiple domains.
2) Set a custom variable to pop with the domain (or full page name) during the event (or just set it when the visitor goes to the domain and set it as session/visit scope). You can then use this as a breakdown dimension. Or, you can use it to create a segment.
3) Restructure the event hierarchy to incorporate the domain. For example, make the top level (category) be the domain (or full page name). I only suggest this as something you can do but ideally you should go with #1 or #2

Resources