Sean Holmesby

.NET and Sitecore Developer

By

Google Analytics Events on Links and Form Submit Buttons

I’ve started using Google’s Universal Analytics on my websites but found (using Fiddler) that events weren’t always triggering on links and form submits.
I initially setup events on these elements so I could track how successfully they were being used across the site, however I found that the page would sometimes be so fast that it would move the user on before Google Analytics could successfully complete the event request.

Initially I thought I would just set a timeout of a couple of seconds to allow for the event request to work, but this wasn’t a great solution.
Eventually I found a callback method, hitcallback, that would allow the event to be triggered before performing the page action. (Source)

$('#linkId').click(function (e) {
	e.preventDefault();
 
	var link = this;
	ga('send', 'event', {
		'eventCategory': 'Cetegory',
		'eventAction': 'Action',
		'eventLabel': 'Label',
		'hitCallback': function () {
			document.location = $(link).attr('href');
		}
	});
});

On the links we prevent the default, trigger the event, then once we know the event request has completed the callback will perform the default action by sending the user to the link location.

The same can be done with form submit buttons. (Source)

$('#btnSubmitId').click(function (e) {
	e.preventDefault();
 
	var btnSubmit = this;
	ga('send', 'event', {
		'eventCategory': 'Category',
		'eventAction': 'Action',
		'eventLabel': 'Label',
		'hitCallback': function () {
			$(btnSubmit).parents('form').first().submit(); // Submit underlying form
		}
	});
});

Here we can see that the default action on the button is prevented, the event is triggered, then the callback performs the submit once the event request has completed.
Note: Ensure your submit button doesn’t have an id or name ‘submit’

Now we’ve ensured that all the events fire appropriately, and we’re getting the correct statistics in our reports.

By

Sitecore Publish Queue and Incremental Publish

I’ve recently been looking into the Publish Queue and using Incremental publish on our projects.
Out of the site publish modes available, Incremental publish is the quickest publishing option.

I wanted to look into how this works.
In the past we’ve always made our updates and individually published every changed item on it’s own. This can be very time consuming so I wanted to see if there’s a better way.

Ways to View the Publish Queue

Using the Sitecore API

I found some different ways to view the publish queue.

Beginning with Brian Pedersen’s blog post I wrote an application that simply lists the publish queue using his ‘current view’ method.

Sitecore.Data.Database master = Sitecore.Data.Database.GetDatabase("master");
Sitecore.Data.Database web = Sitecore.Data.Database.GetDatabase("web");
 
Sitecore.Publishing.PublishOptions options = new Sitecore.Publishing.PublishOptions(master, web, Sitecore.Publishing.PublishMode.Incremental, Sitecore.Globalization.Language.Parse("en"), DateTime.Now);
 
// Get all the publishing candidates
System.Collections.Generic.IEnumerable candidates = Sitecore.Publishing.Pipelines.Publish.PublishQueue.GetPublishQueue(options);

Using Sitecore Rocks

In Rocks you can access the publish queue through the context menu by right clicking on an item in Sitecore Explorer and choosing
Tools -> Publishing -> Publish Queue
Publish Queue - Sitecore Rocks
Publish Queue - Sitecore Rocks

Note: You can also access this quickly using Commandy or by adding the selection to your favourites if you use it often enough.

Looking at the SQL table dbo.PublishQueue

If you open up SQL Server and locate the Publish Queue table in your master database you can view all the entries that Sitecore has made to it.
Publish Queue - SQL Table

Comparing all the queues

When looking at these three options I found that I was getting slightly different subsets in each.
The largest set of results came from the SQL Server table, while the smallest set came from the API code.

I noticed the following:-

  • The SQL table could contain multiple references to the same item. I assume this means that the one item could have been edited multiple times, and been added to the table each time.
  • The Rocks Publishing Queue viewer contained singular references to all items found in the SQL table.
  • The API code gave a subset of the Rocks queue, and only listed items that had been updated relatively recently.

How does incremental publish work with the Publish Queue

The incremental publish works the same way as the API code above. I found that the API code only grabs items that were updated more recently than the date and time of the last incremental publish.
Sitecore stores the date and time of the last publish in the dbo.Properties table for every target database and language.
This can also be accessed in code using:-

Database.Properties.GetLastPublishDate(Database target, Language language)

Code Reference

This is also how the Incremental Publish works. Sitecore grabs all the items from the Publish Queue table that were modified more recently than the last publish date.

By doing this, only recently changed items (in the final workflow state) will be published.

By

Sitecore Access Denied Exception in the Content Editor

Recently I noticed a lot of the following errors coming through from our Sitecore content entry server.

System.Web.HttpUnhandledException (0x80004005): Exception of type 'System.Web.HttpUnhandledException' was thrown. ---> Sitecore.Exceptions.AccessDeniedException: Application access denied.
at Sitecore.Diagnostics.Assert.HasAccess(Boolean accessAllowed, String message)
at Sitecore.Shell.Applications.Analytics.TrackingField.TrackingFieldDetailsPage.OnLoad(EventArgs e)
System.Web.HttpUnhandledException (0x80004005): Exception of type 'System.Web.HttpUnhandledException' was thrown. ---> Sitecore.Exceptions.AccessDeniedException: Application access denied.
at Sitecore.Diagnostics.Assert.HasAccess(Boolean accessAllowed, String message)
at Sitecore.Shell.Applications.Security.SecurityDetails.SecurityDetailsPage.OnLoad(EventArgs e)

Read More

By

Razl Dazl: The Sitecore Database Compare Tool

A while back I blogged about getting the latest data from production back into your local Sitecore instance.
In the post I showed how it was possible to do using Hedgehog Development‘s Team Development for Sitecore.

Now there’s another tool out there that allows you to do this, in a far cleaner way.
The geniuses at Hedgehog have released Razl, a Sitecore database compare tool, which allows you to port content back and forth between Sitecore installations.

Read More

By

Sitecore Rocks: Presentation with the Layout Designer

I originally published this post on the Igloo blog.

Recently I’ve been attempting to setup pages by adding sublayouts and renderings through the interface in Sitecore Rocks. I thought I’d share some of my experiences.

Note: When explaining my findings here I am referring how Sitecore Rocks deals with presentation settings in version 0.7.15.3. These features may change in future versions.

Read More

By

Sitecore MVC: Page Editor friendly Views with Glass Mapper

I originally published this post on the Igloo blog.

Last week Mike Edwards, the creator of Sitecore Glass Mapper, presented version 3 of the new Glass Mapper on the Sitecore Virtual User Group. [Slides here], [Video here]

During the webinar I asked if it was possible to use Glass models in MVC Views, while still having them Page Editor friendly.
After the webinar, Mike held a Google Hangout, and some other developers expressed their interest in how this could be done with Sitecore MVC.

This blog post details how the developers at Igloo enable the page editor using Glass Mapper with Sitecore MVC.

Read More

By

TDS 4.0 – Things you may have Missed

I originally published this post on the Igloo blog.

This blog post is about Hedgehog Development‘s Team Development for Sitecore, and the features in the soon-to-be-released version, TDS 4.0.

While talk around 4.0 has mainly been about the big features like Code Generation, Config Transforms and the Item Merge tool, I thought it’d be good to talk about the small features and improvements that people with access to the Beta may have missed.

The video below goes through little changes like the ability to open an item’s folder in Windows Explorer and the option to Show excluded files from the project. We also mention the updates to the ‘Sync with Sitecore’ window, and the new option to sync with just a single item.

We also go into detail about how you would use the Item Merge tool in a real world scenario, and how TDS 4.0 automatically organises the structure of the project file, meaning less merge conflicts. Yay!

Enjoy.

http://www.youtube.com/watch?v=NQNFQBCK0fA

By

Sitecore TDS 4.0 – Item Merging

I originally published this post on the Igloo blog.

merge1

This blog post is about Team Development for Sitecore by Hedgehog Development, and the new item merging feature in TDS 4.0.

In a webinar on TDS by the Sitecore Virtual User Group, Dan Galvez, a founder of Hedgehog Development, mentioned that TDS 4.0 would include a new tool for merging Sitecore items. This would act in the same way that you’d merge .NET code.

In the past, when you sync with Sitecore you would have to choose to push the entire item either to Sitecore, or to the TDS project. The item merge tool adds more granularity, allowing you to update Sitecore for some fields, and update the TDS project for others.

Read More

By

Sitecore TDS 4.0 – Config Transforms

I originally published this post on the Igloo blog.

This blog post is about Team Development for Sitecore by Hedgehog Development, and the new config transforms feature in TDS 4.0.

Igloo were privileged to obtain the TDS 4.0 beta from Hedgehog recently, to have a play with the latest features.  One of those features that excited me was the inclusion of support for config transformations.

A lot of our projects use config transformations, and have custom code built into the MSBuild file to make these transforms. While TDS v3 had a File Replacement feature that you could use for changing files based on a Visual Studio configuration, it seemed a bit long-winded compared to just transforming the file. Luckily, the Solution Architect at Hedgehog Development, Sean Kearney, announced the config transform feature on his blog back in May, and since then I’ve been busting to get this implemented on our projects.

Read More

By

Team Development for Sitecore – Field Level Deployments

I originally published this post on the Igloo blog.

team

A couple of months back I blogged about the Advanced Usage of Team Development for Sitecore, which included in concept of Field Level Deployments. This blog post revisits Field Level Deployments, and how you could set the value of a new field on a existing items.

Read More